l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 24: LUGOD election season has begun!
Page last updated:
2006 Jun 10 08:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] C and IEEE-754
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] C and IEEE-754



On Wed, Jun 07, 2006 at 02:10:56PM -0700, Richard Harke wrote:
> On Wed June 7 2006 13:30, Micah J. Cowan wrote:
> > On Wed, Jun 07, 2006 at 02:48:36PM -0500, Ken Bloom wrote:
> > > On Wed, Jun 07, 2006 at 03:41:02PM -0400, Peter Jay Salzman wrote:
> > > > I started to read:
> > > >
> > > >    http://www.cs.princeton.edu/introcs/91float/
> > > >
> > > > and came across an interesting comment:
> > > >
> > > >    "Java uses a subset of the IEEE 754 binary floating point standard
> > > > to represent floating point numbers and define the results of
> > > > arithmetic operations. Most machines conform to this standard, although
> > > > some languages (C, C++) do not guarantee that this is the case."
> > > >
> > > > It's a poorly written paragraph, but seems to say that C and C++ don't
> > > > guarantee adherence to the IEEE 754 standard.  If this really is the
> > > > case, why don't they?
> > >
> > > I suppose if your hardware supports something else instead of
> > > IEEE-754, then a conforming C/C++ implementation can use the hardware,
> > > rather than having to emulate IEEE-754.
> >
> > In fact, IIRC, C predates IEEE('s very existance as an orginazation) by
> IEEE is actually quite an old organization around 100 yrs, I believe.
> IEEE has sections for power generation and transmission, and many others,
> not just computers. 

Doh! Of course, you are right. I was guessing on that. I meant to look
it up before saying such a thing, but I forgot.

However, I /believe/ I'm right when I say that it at least predates IEEE
754... which AFAICT comes from ~1987? Of course, I have no idea in what
forms it existed before it become an international standard. Certainly,
it predates C's first forray into standardization.

<snip>

> For a long time, there has been no way in C to control floating pt modes
> but I think recently some effort has been made. Rounding modes in
> particular can be quite important in some computations.
> I think C mostly goes with what is expedient with the hardware in use.
> On x86, the hardware float registers are actually 82 bits. This can be
> accessed directly with some compilers as long double But, OTOH, if you
> specify double it will be expaned to long double when loaded into
> a register. Now if it stays in the register through a series of operations,
> the result can subtly different than if it was rounded to double after
> every intermediate operation.

Yeah. Which was frustrating to implementors, because in order to be 100%
conforming, they _had_ to do the stupid truncations every single
operation. Which is why GCC added -funsafe-math-operations, I think.

So C99 (1) allowed these optimizations to take place by default, and (2)
defined a standard #pragma directive to control it (FP_CONTRACT).

Of course, this is all AIUI: I haven't nearly the intimate knowledge of
C and floating-point that many implementors and various folks at
comp.lang.c have; so better to check with them for details.

-- 
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.