473,382 Members | 1,373 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,382 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 1992
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.