By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,017 Members | 1,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,017 IT Pros & Developers. It's quick & easy.

ANSI Standard : HUGE_VAL * 0.0

P: n/a
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

Feb 7 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Satish" <sa*************@gmail.comwrites:
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
--
"If I've told you once, I've told you LLONG_MAX times not to
exaggerate."
--Jack Klein
Feb 7 '07 #2

P: n/a
Ben Pfaff <bl*@cs.stanford.eduwrites:
"Satish" <sa*************@gmail.comwrites:
[snip]
>Also is there anywhere I can download ANSI standards for C/C++?

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 Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 7 '07 #3

P: n/a
On Feb 7, 5:57 pm, Keith Thompson <k...@mib.orgwrote:
Ben Pfaff <b...@cs.stanford.eduwrites:
"Satish" <satishsantha...@gmail.comwrites:

[snip]
Also is there anywhere I can download ANSI standards for C/C++?
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 Thompson (The_Other_Keith) k...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Keith and Ben thanks for your quick replies. It helped me.

Thanks again,
Satish

Feb 7 '07 #4

P: n/a
Satish wrote:
>
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

Feb 8 '07 #5

P: n/a
On Feb 7, 5:35 pm, Ben Pfaff <b...@cs.stanford.eduwrote:
"Satish" <satishsantha...@gmail.comwrites:
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
--
"If I've told you once, I've told you LLONG_MAX times not to
exaggerate."
--Jack Klein
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

Feb 10 '07 #6

P: n/a
Satish wrote:
>
.... 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 <opanything = 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
Feb 10 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.