3 ms·
That's not entirely accurate. See slide 1, bottom right: http://courses.cs.vt.edu/~cs3214/fall2011/gback/lectures/Lecture6-ia32-floatingpoint-advanced.pdf http:
by scott_s 14y ago
That's not entirely accurate. See slide 1, bottom right: http://courses.cs.vt.edu/~cs3214/fall2011/gback/lectures/Lecture6-ia32-floatingpoint-advanced.pdf http://courses.cs.vt.edu/~cs3214/fall2011/gback/lectures/Lec...
And: http://en.wikipedia.org/wiki/X87 http://en.wikipedia.org/wiki/X87
Basically, if you're using x87 for the floating point calculations, then it's possible for partial results to be 80-bits, and what values you observe can depend on when you write them back to memory (which will round them to 64-bits).
- acqq 14y agoHave you checked the code produced by your compiler and standard library? I don't know of any which uses 80 bits mode. Unless you turn on the 80 bits yourself, you don't use them. If you find such compiler please write! Another thing is that by the C standard, all calculations are performed on doubles, even when the result is to be stored as float. It's an ABC of C. :)
- emkemp 14y ago"all calculations are performed on doubles" is only true for traditional C. ANSI C permits single precision arithmetic if there are no double precision terms involved. Of course, C89 only provided standard math functions with double precision arguments, but C99 corrected that.
- acqq 14y agoYou are very correct, "permits." In practice the programmer must really be specific in the code, how he writes the constants (doubles are default) which functions he calls (doubles are default) and how he configures compiler (double intermediates were traditionally faster and defaults). There's a nice article on that topic: http://news.ycombinator.com/item?id=5138351 http://news.ycombinator.com/item?id=5138351 And it's just a part of the whole series of the nice FP articles.