Main Site Documentation

GHI spider Processor and Floating Point


#1

What specific ARM-7 processor chip does the GHI Spider use?
Does it provide hardware floating point.

I tried
:


double eps = 1.0

while (true) {
  if (1.0+eps == 1.0) break
  eps /= 2.0
}

and put eps on the display with eps.ToString()

eps is approximately 1.1e-16


#2

floating point is supported in NETMF, not matter if the processor supports it or not. ARM7 do not have floating point.


#3

I do not understand why my code calculates eps as approximately 1.1e-16.
A double is 8 bytes…

OOPS - Sorry. on a 32-bit machine, eps is 1.1e-16.

Tom Dean


#4

What answer did you expect?

Your code will loop until eps gets small enough that the code considers 1.0 + eps to be close enough to 1.0 that the equality test becomes true.


#5

Forgot to say, welcome to the community.


#6

Thanks, Mike.

I slipped a cog - been working 64 bits for a while…


#7

Something that surprises a lot of programmers when they first learn it is that floating point types (float and double) are merely approximations. There is no way to represent an arbitrary floating point number with a fixed storage space, so the IEEE came up with a clever way to store and manipulate approximations. This is the method used by all computers today (that I’m aware of, at least…). The standard is called IEEE 754, and you can read all about it here: http://en.wikipedia.org/wiki/IEEE_754-2008

This IEEE standard is used both by hardware FPUs in processors (such as the one in a Cerberus), as well as software implementations (such as that used by the ARM7 in your Spider).

Double is more accurate, but it’s still an approximation. If your situation cannot tolerate these approximations and rounding errors, then you might be able to use the decimal type. It doesn’t use IEEE floating point numbers, but in turn, it cannot represent as many different values. It’s up to you to pick your solution.


#8

Yes, I understand…

I was not thinking when I posted. Been working with quadmath and gcc46 for the past few days.

Tom Dean


#9

libquadmath is still dealing in approximations, however, it just deals in more ACCURATE approximations. If you want arbitrary precision, MPFR might be for you :wink: