Re: Calculator problem on ARM board

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

kartikay Malhotra wrote:
> Hello All,
> I am facing a problem. I have a calculator application, which has 14 bit
> screen. When I add two numbers, number1 += number2, where both number1 and
> number2 are double, and one of the numbers is very large, and the other
> number is small, I get an error in result.

Welcome to the world of floating-point math.  High dynamic range, but depending
on where you are at magnitude-wise the precision can be pretty low.

> For example, 10000000000000 + 1 gives 1e+13, instead of 10000000000001. This
> is because the result string  is actually 10000000000000.99.

Yep.  That's a big number, and you don't have the precision to represent it as
accurately as you want.

> Is there a problem in the compiler, or is double precision arithmetic
> incorrect? The same application complied for x86 gives no error.

Well, if both systems conform to ieee695 then the results should be identical.
Is one machine soft-float and the other using an FPU?  Note that for ARM, the
FPU might be emulated by kernel code, so you are actually using a different
runtime implementation than x86.  For apples-to-apples comparisons, use
soft-float everywhere.


Bill Gatliff

List admin:

[Linux ARM]     [Linux ARM MSM]     [Linux ARM Kernel]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

Add to Google Follow linuxarm on Twitter