473,326 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

max{f | f is a float and -f is a float and doesn't cause overflow}== ?

What is the biggest float number f so that -f doesn't overflow and is
still representable as a float.

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.
Nov 14 '05 #1
10 1987
Alexander Malkis wrote:

What is the biggest float number f so that -f doesn't overflow and is
still representable as a float.


FLT_MAX, defined in <float.h>. This value will be
different on different C implementations, but will always
be at least 1e37.

--
Er*********@sun.com
Nov 14 '05 #2

"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> a écrit dans le
message de news:c5***********@hades.rz.uni-saarland.de...
What is the biggest float number f so that -f doesn't overflow and is
still representable as a float.
The <float.h> header provides lots of stuff concerning floating-point
numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
values respectively for the minimum et maximum values for the type float.
The values are implementation defined.
Therefore, to anwer your question, if f is positive, -f doesnt overflow
until f doesn't exceed -FLT_MIN, if f is negative, -f doesnt overflow until
f doesn't exceed -FLT_MAX.

Regis

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.

Nov 14 '05 #3
"Régis Troadec" wrote:

"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> a écrit dans le
message de news:c5***********@hades.rz.uni-saarland.de...
What is the biggest float number f so that -f doesn't overflow and is
still representable as a float.


The <float.h> header provides lots of stuff concerning floating-point
numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
values respectively for the minimum et maximum values for the type float.
The values are implementation defined.
Therefore, to anwer your question, if f is positive, -f doesnt overflow
until f doesn't exceed -FLT_MIN, if f is negative, -f doesnt overflow until
f doesn't exceed -FLT_MAX.


No; you've misunderstood FLT_MIN:

5.2.4.2.2 Characteristics of floating types <float.h>
[...]
/10/ The values given in the following list shall be
replaced by constant expressions with implementation-
defined (positive) values that are less than or equal
to those shown:
[...]
-- minimum normalized positive floating-point number,
[...]
FLT_MIN 1E-37

IMHO the name FLT_MIN is misleading on two counts. First,
it looks just like INT_MIN and LONG_MIN and so forth, but has
a meaning that is not at all analogous to those. Second, it
is not necessarily the minimum positive value distinguishable
from 0.0f; an implementation that supports "denormal" numbers
(most do, nowadays) can represent values that are smaller than
FLT_MIN but greater than zero. Misleading or not, though, the
name is part of the Standard and we'll just have to deal with
it by remembering what it isn't.

--
Er*********@sun.com
Nov 14 '05 #4
"Régis Troadec" <re**@wanadoo.fr> writes:
Therefore, to anwer your question, if f is positive, -f doesnt overflow
until f doesn't exceed -FLT_MIN, if f is negative, -f doesnt overflow until
f doesn't exceed -FLT_MAX.


FLT_MIN has little or nothing to do with overflow. It is the
minimum normalized positive float. Its value is greater than 0
and less than or equal to 1e-37.
--
Just another C hacker.
Nov 14 '05 #5
"Regis Troadec" <re**@wanadoo.fr> wrote:
: The <float.h> header provides lots of stuff concerning floating-point
: numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
: values respectively for the minimum et maximum values for the type float.
: The values are implementation defined.
: Therefore, to anwer your question, if f is positive, -f doesnt overflow
: until f doesn't exceed -FLT_MIN, if f is negative, -f doesnt overflow until
: f doesn't exceed -FLT_MAX.

Methinks you're mixing up FLT_MIN (tiny, positive) and -FLT_MAX (huge, negative).

--
mail to ike at iae dot nl
Nov 14 '05 #6

"Régis Troadec" <re**@wanadoo.fr> a écrit dans le message de
news:c5**********@news-reader4.wanadoo.fr...

"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> a écrit dans le message de news:c5***********@hades.rz.uni-saarland.de...
What is the biggest float number f so that -f doesn't overflow and is
still representable as a float.
The <float.h> header provides lots of stuff concerning floating-point
numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
values respectively for the minimum et maximum values for the type float.
The values are implementation defined.
Therefore, to anwer your question, if f is positive, -f doesnt overflow
until f doesn't exceed -FLT_MIN, if f is negative, -f doesnt overflow

until f doesn't exceed -FLT_MAX.
Arghhh, BULLSHIT !! Some confusion : I answered as if it were with integers.
Not the same.

FLT_MAX is only useful.

Regis

Regis

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.


Nov 14 '05 #7

"Ike Naar" <no****@nospam.invalid> a écrit dans le message de
news:4f*****************@typhoon.bart.nl...
"Regis Troadec" <re**@wanadoo.fr> wrote:
: The <float.h> header provides lots of stuff concerning floating-point
: numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
: values respectively for the minimum et maximum values for the type float. : The values are implementation defined.
: Therefore, to anwer your question, if f is positive, -f doesnt overflow
: until f doesn't exceed -FLT_MIN, if f is negative, -f doesnt overflow until : f doesn't exceed -FLT_MAX.

Methinks you're mixing up FLT_MIN (tiny, positive) and -FLT_MAX (huge, negative).

In fact, I really misunderstood it as Eric and Ben said. I answered too
quickly as if it were integers and had some confusion between FLT_MIN and
INT_MIN.

Regis

--
mail to ike at iae dot nl

Nov 14 '05 #8
And how about an int? On my impl, one of -INT_MIN and -INT_MAX is not
representable.

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.
Nov 14 '05 #9

"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> a écrit dans le
message de news:c5***********@hades.rz.uni-saarland.de...
And how about an int? On my impl, one of -INT_MIN and -INT_MAX is not
representable.
The absolutes values of INT_MIN and INT_MAX may be different, so
either -INT_MIN either -INT_MAX isn't representable. Often, the absolute
value of the minimum is greater than the absolute value of the maximum
(perhaps because of 2's complement ?), then, -INT_MIN may not be
representable on your implementation, because it's greater than INT_MAX.

The bullshits I said about floating point numbers can now be applied to
integers ;-)
If an int, say n, is negative, then -n is representable if it (-n) doesn't
exceed INT_MAX.
If n is positive, then -n is representable if it doesn't exceed INT_MIN.

The header <limits.h> provides all you need to safely control the values of
your integers.
According to the type of your signed integers, other useful macros are
SCHAR_MIN(MAX) for signed char, SHRT_MIN(MAX) for short int, LONG_MIN(MAX)
for long int, and in C99, LLONG_MIN(MAX) for long long int.

Regis

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.

Nov 14 '05 #10
Régis Troadec wrote:
If an int, say n, is negative,
then -n is representable if it (-n) doesn't exceed INT_MAX.
If n is positive,
then -n is representable if it doesn't exceed INT_MIN.


If n is positive,
then there's no problem with -n exceeding any limits.

--
pete
Nov 14 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Wolfgang Meier | last post by:
Hi, Although it might seem like I am firing out random posts in quick succession this matter is indeed one I thought about for quite some time without coming to a conclusion: Why is it that...
10
by: Alexander Malkis | last post by:
What is the biggest float number f so that -f doesn't overflow and is still representable as a float. -- Best regards, Alex. PS. To email me, remove "loeschedies" from the email address...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
16
by: Martijn Mulder | last post by:
Why is there a type float in C#? Working with integers is best, of course. It is like carrying pebbles around in your pocket. But if you need decimal floating point values, in graphics...
35
by: Frederick Gotham | last post by:
I'm writing a template, and I need to know the maximum value of a given integer type at compile time. something like: template<class NumType> class Arb { public: static NumType const max =...
2
by: howa | last post by:
<html> <head> <style> ..left { float : left; } ..left { float : right; }
27
by: GloStix | last post by:
WARNING VIDEO TAKES A WHILE TO LOAD http://screencast.com/t/BWQ6DNtsM I really don't know how to fix this other than putting another div. But I dont' exactly want to do that for every page....
15
dlite922
by: dlite922 | last post by:
I'm back again, Intro: I've got a floating div (outerDIV) with fixed width that contains an image (IMG) and a div that contains a short text (innerDIV) Problem: In FF, the innerDIV is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.