|
|
|
Re: Calculator problem on ARM board | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
|
On Wed, 5 Nov 2008, 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.
>
> For example, 10000000000000 + 1 gives 1e+13, instead of 10000000000001. This
> is because the result string is actually 10000000000000.99.
>
> Is there a problem in the compiler, or is double precision arithmetic
> incorrect? The same application complied for x86 gives no error.
What is your compiler version?
I wrote this little test code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char*argv[])
{
double a = strtod(argv[1], NULL);
double b = strtod(argv[2], NULL);
printf("%f + %f = %f\n", a, b, a + b);
return 0;
}
And here's the result I obtain:
$ double_add_test 10000000000000 1
10000000000000.000000 + 1.000000 = 10000000000001.000000
This is with gcc 4.1.2 configured for an EABI environment using
soft-float.
Nicolas
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
[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]
![]() |
![]() |