Any Decent Math Library Available?

But does it provide the IEEE-754 format for the 4 bytes?

Not sure if it is IEEE-745 but I am near positive. The representation is exactly how it is internally in RAM so it should be IEEE

Well, from another post - Convert Float to 4 byte array? you mentioned string conversion.

So now I am confused. Can you verify that a 32 bit float can be converted into its IEEE-754, 4 byte format and vise versa?

Can you show a code snippet?

Thanks…

Yes that was before the latest firmware where we added the new function, I mentioned earlier. You probably didn’t look at the function I mentioned at all.
Here is an example!


using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.System;
class Program
{
    public static void Main()
    {
        float f = 15.23f;
        byte[] buff = new byte[4];
        // float to byte array
        Util.InsertValueIntoArray(f, buff, 0);
        

        // back from byte array to float
        float newf;
        Util.ExtractValueFromArray(out newf, buff, 0);

        //verify
        Debug.Print("f = " + f);
        Debug.Print("newf = " + newf);
        
        Thread.Sleep(-1);
    }
}

Is this the release candidate software from 4/26/10 that is listed on the main page?

Thanks,

Yes. Please see documentation

Well, it does not appear to be in IEEE 754 format.

Take each byte value of buff and convert to binary (00010100101011100111001101000001) and check on this web site:
http://www.h-schmidt.net/FloatApplet/IEEE754.html

I don’t get a value of 15.23.
It comes out as 1.761497E-26.

Can you guys make it so it does the correct format?

Thanks…Tony

Actually, I just noticed the bytes are reversed.
So if you take buff[3] as the first byte and then on down to buff[0] it is in the correct format for IEEE 754.

So good deal!

Thanks,
Tony

The order is correct to our processor which make sense, the LSB is at index 0. Other systems may have bytes ordered the other around.

Thanks guys!

Now if we can just get a good math library - then some great apps can be realized!

-Tony

ah the good ol’ battle between little and big endian.
If I had a nickel for every time I ran into that over the years :stuck_out_tongue:

I am using the Micromega fpu in my autonomous boat calculations. With the precision of IEEE 754 numbers, I can only get within about twenty feet at longitudes greater than 100 degrees.

I wil be trying to write the needed trig funcitons for double precision using the math namespace sin and cos and trig identities. Will let you know.

Yes you can wrap everything in a class that uses uMega FPU chip.

Using the Micromega chip will give a resolution of a Single data type. This is only seven decimal digits.

What is needed for robotic navigation is a Double type where you get 16 decimal digits.

I thought the chip provided double! I guess misunderstood.

Anyway, the plan is to add support for double built right in FEZ. No promises yet on what will be supported, we are simply still looking into options.

I have the Micromega uMFPU chip working with my FEZ Domino now and it’s doing the floating point great circle and bearing calculations with single precision (the chip only supports float or single). The numbers are decent and I get somewhat close to my VB.NET application which is using double.

If we can get double with FEZ or .NETMF that would solve a bunch of problems (no pun intended!).

-Tony

If you like, can you share the code needed to use the fpu chip?

Sure, I would like to see your fpu chip code and so might others.

Thanks…

We have added many math functions to FEZ. You can now do it all :slight_smile:

Is this in the next software release?

Thanks…