Data types

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have an application that really needs the use of a double variable. I have written code using AVR Studio and WinAVR but I don't seem to get the expected accuracy with the double variable. I came across some documentation that indicates the float and double types are one and the same. Can someone confirm the validity of this? If this is true, are there any workarounds, open source libraries or efforts in the works that would permit the precision of a true double?

-Thanks-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well if it's stated in the manual (it is) then is there some reason to doubt it?

Both double and float are both IEEE754 32 bit numbers giving about 8.5 digits of accuracy.

I'm intrigued to know what kind of microcontroller app needs accuracy beyond this - are you targetting a laser onto a sixpence left on the moon or something?

One possible workaround might be to have a look at IBM's library for decimal arithmetic which may well be adopted as IEEE 754r (when the arguing finally stops!) but an implementation will probably require quite a big AVR to accomodate it.

Cliff

PS it's kind of coincidental that the one of the avr-libc coordinators was, this very day, looking for someone to add 64bit double support to avr-libc - so if you roll your own you might consider donating it to the greater good!