delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq090.html   search  

| Previous | Next | Up | Top |

11.6 Floating point inaccuracies when using emulator

Q: I am experiencing inaccurate results in some floating point calculations, sometimes in the 2nd or 3rd significant digit (like getting 118.401 instead of 120.0). This is really unacceptable! (And no, I'm not using a buggy Pentium CPU.)


A: Are you using the emulator? If so, it might be that the emulator isn't as accurate as you expect. One particular known problem is that it does a bad job when computing the atan function. So if you use atan(1.) to get the value of Pi, that might be your problem. Solution: make Pi a constant, as God intended. The header file <math.h> includes the constant M_PI which you can use; or get the value of Pi from the net.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright ⌐ 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)