How do I find out if my embedded system has Floating Point Unit(FPU)? I'm using Keil tools. Our target board uses NXP LPC2468 series Microcontroller ? Does this microcontroller have FPU? Looking in the microcontroller manual I couldn't find any information on FPU.
By looking in the Datasheet (or "manual" or whatever the particular manufacturer calls it).
"in the microcontroller manual I couldn't find any information on FPU"
That'll be because it doesn't have one, then.
Manufacturers document what is present on the chip - they don't tend to make an exhaustive list of all features that could ever possibly be included in any processor, and say "not fitted" to all the ones that aren't present!
Given: 5351 minutes My embedded application needs to: 5351/60 = 89.18333.. Then, I would send 891 or 892 to PC application. They would divide by 10 and display 891 or 892 hours.
Not to appear retarded, but wouldn't (5351 + 3) / 6 do this
Or more generally y = (x + 3) / 6
To answer your other questions, yes Keil has software floating point libraries, ARM has had routines since inception. GNU/GCC also has math libraries (libm.a)
Generally fixed point is implemented by a user who understands the range of the number space they plan on supporting, and they chose a representation which is appropriate. If you understand math, the methods to eliminate the use of floating point should be fairly apparent.
Not sure shifting helps here, you're attempting to represent numbers in decimal, not binary, as you transmit them. Fixed point would shift the number and provided additional precision. You'd pull out the integer portion first, and then multiply by 10 to extract the fractional digits. Frankly scaling makes more sense here than shifting.
>> Not to appear retarded, but wouldn't (5351 + 3) / 6 do this >> Or more generally y = (x + 3) / 6
Yes, it would. I can't understand how. Please explain how you arrived at this formula.
Basic math facts:
60 / 10 = 6
60 / 2 = 30
1 / 2 = 0.5
0.5 * 60 = 30 Multiply by reciprocal, it's computationally cheaper
30 / 10 = 3
0.5 * 6 = 3
Done in floating point
TenthsOfHours = (int)(((Mins / 60.0) * 10.0) + 0.5); // Rounding up
In order to maintain precision with integer math we need to move the divide to the final operation = (((Mins * 10.0) / 60.0) + 0.5) = (((Mins * 1.0) / 6.0) + 0.5) = ((Mins / 6.0) + 0.5) = ((Mins + 3.0) / 6.0) = ((Mins + 3) / 6)
Thank you for explaining in detail.
I already knew basic math facts.
Thanks again! That was very helpful!
Somehow integer arithmetic is so often forgotten just because pocket calculators and PC:s can do floating point.