Think you. I modified my source :
printf("%lu * %bu = ", N, M); printf("%lu\n", Freq); Freq=25690112L; printf("%lu * %bu = ", Freq, 4); Freq*=4; printf("%lu\n", Freq);
It work correctly. but the Long Integer Multiple fault also.
Run Result: 24500000 * 4 = 4294926936 25690112 * 4 = 1568
i give you answer in other thread!!!
what you expect???
24500000 * 4 = 98000000
NO
biggest unsigned long integer is 4294967296 biggest signed integer is 2147483647
on keil the long integer is 32 bits
you have a maths overflow!!!
in c an integer maths overflow can give undefinededed result
it normally wraps but not is guaranteeed
referr to ansi c book
float maths give error value you think
Yes, I expect the result is: 24500000 * 4 = 98000000
I defined the variable as unsigned long, and unsigned long range is 0..4294967295. The 9800000 is far smaller than 4294967295, so I think there may exists a bug of Long Integer Multiple.
When I disable the "Use On-chip Arithmetic Accelerator" on Target Options, the program runs correctly.
"Use On-chip Arithmetic Accelerator"
what chip is that?
are you one more of those that expect the simulator to simulate exotic chips fully?
see my general comment at http://www.keil.com/forum/docs/thread9976.asp
Erik
View all questions in Keil forum