ANSI Standard : HUGE_VAL * 0.0

S

Satish

Hi ,

What is the behaviour as per ANSI standard for HUGE_VAL * 0.0? Also
is there anywhere I can download ANSI standards for C/C++?

Thanks,
Satish
 
B

Ben Pfaff

Satish said:
What is the behaviour as per ANSI standard for HUGE_VAL * 0.0?

The standard doesn't say. It could be a NaN or 0, for example.
Also is there anywhere I can download ANSI standards for C/C++?

webstore.ansi.org
 
K

Keith Thompson

S

Satish

Ben Pfaff said:

[snip]
webstore.ansi.org

n1124.pdf is the ISO C99 standard with two Technical Corrigenda merged
into it (the changes are marked with change bars). I have a copy of
the C99 standard itself (I paid $18 for it), but I usually use n1124
intead.

<http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf>

I don't know about C++. Ask in comp.std.c++ or comp.lang.c++ -- but
check their FAQ first.

Keith and Ben thanks for your quick replies. It helped me.

Thanks again,
Satish
 
C

CBFalconer

Satish said:
What is the behaviour as per ANSI standard for HUGE_VAL * 0.0?
Also is there anywhere I can download ANSI standards for C/C++?

No, there is no standard for C/C++. If you want a standard for a
extant language, such as C or Pascal or Ada, or even (shudder) C++,
the answer might be different, and it would probably be an ISO
standard.

Googling for N869 or N1124 might be illuminating.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
S

Satish

The standard doesn't say. It could be a NaN or 0, for example.


webstore.ansi.org

Hi,

With your statement above my project could have been using a bad
design for years. Mine is a computationally intensive project. We
used to initialize variables with HUGE_VAL and project lived with it
even many comparison might have gone wrong when val * 0.0 was used.
As we moved to new compilers we identified this problem because the
new compiler returns NaN. So initializing to HUGE_VAL to my opinion
is bad design. At the sametime I cannot assign the variable with 0
because for example I use a check if val == HUGE_VAL update database
as NULL. I cannot do like val == 0 because the value indeed may be
computed to 0. So I was wondering do you think it is a good idea to
initialize variable with NaN. Does the standard say anything for NaN
* 0.0? At least the popular math functions when operated with NaN or
invalid values like fmod(-HUGE_VAL, 0) do they return HUGE_VAL or NaN?

Thanks,
Satish
 
C

CBFalconer

Satish said:
.... snip ...

With your statement above my project could have been using a bad
design for years. Mine is a computationally intensive project. We
used to initialize variables with HUGE_VAL and project lived with it
even many comparison might have gone wrong when val * 0.0 was used.
As we moved to new compilers we identified this problem because the
new compiler returns NaN. So initializing to HUGE_VAL to my opinion
is bad design. At the sametime I cannot assign the variable with 0
because for example I use a check if val == HUGE_VAL update database
as NULL. I cannot do like val == 0 because the value indeed may be
computed to 0. So I was wondering do you think it is a good idea to
initialize variable with NaN. Does the standard say anything for NaN
* 0.0? At least the popular math functions when operated with NaN or
invalid values like fmod(-HUGE_VAL, 0) do they return HUGE_VAL or NaN?

NaN <op> anything = NaN.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top