Searching \ for '[OT]: Floating point formats' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=floating+point+formats
Search entire site for: 'Floating point formats'.

Exact match. Not showing close matches.
PICList Thread
'[OT]: Floating point formats'
2002\08\24@161608 by Jim

flavicon
face
Big Endian/Little Endian problem perhaps?

What kind of processor is on the other end
of this comm link?

Is the comm link doing a full eight bits - does
it perhaps recognize any particular control
characters that the data could represent?

What format does the characteristic and the mantissa
(of the FP number) take?

RF (and software) Jim

   "Our ability to manufacture fraud has exceeded
    our  ability to detect it."

    - Al Pacino as Viktor Taransky in the movie 'Simone'



{Original Message removed}

2002\08\24@164900 by Claudio Tagliola

picon face
Hi,


The other end is a PC and a PIC with CCS C. I know
of the difference between the IEEE754 (PC) and the
PIC floating point format. The difference here is just
that the sign bit is in a different location. However, the
bitpattern I see on this processor has nothing in
common with what I get on the Pic. It's not just BE/LE.

Two examples:

float 6.0 on PIC:               81 40 00 00
float 6.0 on A186:      00 00 C0 40

And:

float 2.0 on PIC:               80 00 00 00
float 2.0 on A186:      00 00 00 1F

This has some similarity. However:

float 0.1 on PIC:               7B 4C CC CD
float 0.1 on A186:      9B CC CC 9D

Any patterns? More samples can be constructed on
demand.

Communication is working correct on 8 bits. It's over
serial, CAN and TCP/UDP, so no control characters
there. The format I want it in is the following (from
low to high):

8 bit exponent with bias of 7F
1 sign bit
23 bit mantissa

Now, I know some FP manipulations, but I can't seem
to get this one.


Regards,
Claudio

-----Oorspronkelijk bericht-----
Van: pic microcontroller discussion list
[spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU]Namens Jim
Verzonden: zaterdag 24 augustus 2002 21:58
Aan: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
Onderwerp: Re: [OT]: Floating point formats


Big Endian/Little Endian problem perhaps?

What kind of processor is on the other end
of this comm link?

Is the comm link doing a full eight bits - does
it perhaps recognize any particular control
characters that the data could represent?

What format does the characteristic and the mantissa
(of the FP number) take?

RF (and software) Jim

   "Our ability to manufacture fraud has exceeded
    our  ability to detect it."

    - Al Pacino as Viktor Taransky in the movie 'Simone'

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2002\08\24@171522 by Claudio Tagliola

picon face
Hi all,


Extra examples of the AMD186, hope it helps:

1.000000        00 00 80 3f
-1.000000       00 00 80 bf
2.000000        00 00 00 40
-2.000000       00 00 00 c0
4.000000        00 00 80 40
-4.000000       00 00 80 c0
8.000000        00 00 00 41
-8.000000       00 00 00 c1
65536.000000    00 00 80 47
-65536.000000   00 00 80 c7

0.500000        00 00 00 3f
-0.500000       00 00 00 bf
0.250000        00 00 80 3e
-0.250000       00 00 80 be
0.125000        00 00 00 3e
-0.125000       00 00 00 be
2.500000        00 00 20 40
-2.500000       00 00 20 c0
6.125000        00 00 c4 40
-6.125000       00 00 c4 c0


Regards,

Claudio

-----Oorspronkelijk bericht-----
Van: pic microcontroller discussion list
[.....PICLISTKILLspamspam.....MITVMA.MIT.EDU]Namens Jim
Verzonden: zaterdag 24 augustus 2002 21:58
Aan: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
Onderwerp: Re: [OT]: Floating point formats


Big Endian/Little Endian problem perhaps?

What kind of processor is on the other end
of this comm link?

Is the comm link doing a full eight bits - does
it perhaps recognize any particular control
characters that the data could represent?

What format does the characteristic and the mantissa
(of the FP number) take?

RF (and software) Jim

   "Our ability to manufacture fraud has exceeded
    our  ability to detect it."

    - Al Pacino as Viktor Taransky in the movie 'Simone'



{Original Message removed}

2002\08\25@200824 by Michael F. Coyle

flavicon
face
----- Original Message -----
From: "Claudio Tagliola" <tagliolaspamspam_OUTSOFTHOME.Spammers.Are.Scum.NET>> Newsgroups: comp.arch.embedded.piclist
To: <
@spam@PICLISTKILLspamspamMITVMA.RemovE.MIT.EDU>
Sent: Saturday, August 24, 2002 4:49 PM
Subject: Re: [OT]: Floating point formats


> Hi all,
>
>
> Extra examples of the AMD186, hope it helps:
>
> 1.000000        00 00 80 3f
> -1.000000       00 00 80 bf

[Much Snippage]

I've looked at your examples; the numbers in both formats are IEEE but they
are laid out differently.  If you're still interested I can describe in
detail how to interpret them.  (This is my first post to the PICLIST and I
want to keep it short until I know that my post has gotten through.)

- Michael

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads



'[OT]: Floating point formats'
2002\09\02@093437 by Claudio Tagliola
picon face
       Hello Michael,


I've been out of office for a week, did a very ugly workaround (multiply the
values by
10 and convert them to signed int, as I mostly only needed 0.1 resolution).

Your message did come through. If you have information on how to go back and
forth between the two, I would be helped tremendously.


       Regards,

       Claudio

-----Oorspronkelijk bericht-----
Van: pic microcontroller discussion list
[KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU]Namens Michael F. Coyle
Verzonden: maandag 26 augustus 2002 1:55
Aan: RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU
Onderwerp: Re: [OT]: Floating point formats


{Original Message removed}

2002\09\02@213906 by Michael F. Coyle

flavicon
face
Hi Claudio,

You wrote:
    I've been out of office for a week, did a very ugly workaround
(multiply the
    values by 10 and convert them to signed int, as I mostly only needed
0.1 resolution).

    Your message did come through. If you have information on how to go
back and
    forth between the two, I would be helped tremendously.

Both formats are similar to each other.  The 186 format is IEEE-754 with the
low byte
first (little endian).  The leading 1 in the significand is omitted in order
to store
an additional significant bit.  The exponent is stored excess-127.  To
interpret this
format:

1. Take the original number.  We'll use the first example below: 00 00 C0 40
2. Write the bytes in reverse order: 40 C0 00 00
3. Convert to binary: 01000000110000000000000000000000
4. Split into three fields, of 1, 8, and 23 bits respectively:
  0 10000001 10000000000000000000000
5. The first field is the sign: 0 for plus, 1 for minus.  Here it's 0
(plus).
6. The second field is the exponent, excess-127.  Here, 10000001 is 129
decimal.  129-127=2
  so the actual exponent is 2.
7. Take the third field and put "1." in front of it to restore the 1 bit
removed when the
  number was formed: 1.10000000000000000000000 (in decimal, 1.5)
8. The number is now +1.5 * 2**2 = +1.5 * 4 = +6.0 (here ** indicates
exponentiation)

The PIC format is similar except that the top byte comes first (big endian)
and the
sign bit is placed *after* the exponent.  Using the first example below:

1. Take the original number: 81 40 00 00
2. Convert to binary: 10000001010000000000000000000000
3. Split into three fields, of 8, 1, and 23 bits respectively:
  10000001 0 10000000000000000000000
4. The first field is the exponent, excess-127.  Here, 10000001 is 129
decimal.  129-127=2
  so the actual exponent is 2.
5. The second field is the sign: 0 for plus, 1 for minus.  Here it's 0
(plus).
6. Take the third field and put "1." in front of it to restore the 1 bit
removed when the
  number was formed: 1.10000000000000000000000 (in decimal, 1.5)
7. The number is now +1.5 * 2**2 = +1.5 * 4 = +6.0 (here ** indicates
exponentiation)


Checking against your first set of examples:

    float 6.0 on PIC:               81 40 00 00
OK; format is PIC, big endian, as described above.

    float 6.0 on A186:      00 00 C0 40
OK; format is IEEE, little endian, as described above.

    float 2.0 on PIC:               80 00 00 00
OK; format is PIC, big endian, as described above.

    float 2.0 on A186:      00 00 00 1F
This doesn't look right; I think it ought to be 00 00 00 40 in IEEE format.
This is
the same value you supply in the next set of examples.  Can you confirm
this?

    float 0.1 on PIC:               7B 4C CC CD
OK; format is PIC, big endian, as described above.

    float 0.1 on A186:      9B CC CC 9D
This doesn't look right either; I think it ought to be CD CC CC 3D.  Can you
confirm this?


    Extra examples of the AMD186, hope it helps:

    1.000000        00 00 80 3f
    -1.000000       00 00 80 bf
    2.000000        00 00 00 40
    -2.000000       00 00 00 c0
    4.000000        00 00 80 40
    -4.000000       00 00 80 c0
    8.000000        00 00 00 41
    -8.000000       00 00 00 c1
    65536.000000    00 00 80 47
    -65536.000000   00 00 80 c7
These are all OK; format is IEEE, little endian, as described above.

    0.500000        00 00 00 3f
    -0.500000       00 00 00 bf
    0.250000        00 00 80 3e
    -0.250000       00 00 80 be
    0.125000        00 00 00 3e
    -0.125000       00 00 00 be
    2.500000        00 00 20 40
    -2.500000       00 00 20 c0
    6.125000        00 00 c4 40
    -6.125000       00 00 c4 c0
These are OK, too, same format as above.


    The format I want it in is the following (from low to high):

    8 bit exponent with bias of 7F
    1 sign bit
    23 bit mantissa

You've already got it but the bits may not be where you expect them to be.
You can convert from one to the other by mapping the floating point number
to a 32-bit unsigned integer and doing some bit shifting and masking.  If
you
have any problem with this I can give you a hand.  You can do the conversion
at either the PIC end or the 186 end of the communication.

By the way, zero is a special case in IEEE format.  It is stored as
all-bits-zero
and should not be interpreted by the above algorithm.  Instead, you should
check
for all bits zero as a special case first.

You should check the PIC format for the representation of zero.  It's
probably
also 00 00 00 00 but you should confirm this.

Hope this all helps.

- Michael

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2002\09\03@042324 by James Hillman

flavicon
face
On Sat, 24 Aug 2002 22:55:31
Claudio Tagliola wrote:
<<<
1.000000        00 00 80 3f
-1.000000       00 00 80 bf
2.000000        00 00 00 40
-2.000000       00 00 00 c0
4.000000        00 00 80 40
-4.000000       00 00 80 c0
8.000000        00 00 00 41
-8.000000       00 00 00 c1
65536.000000    00 00 80 47
-65536.000000   00 00 80 c7

0.500000        00 00 00 3f
-0.500000       00 00 00 bf
0.250000        00 00 80 3e
-0.250000       00 00 80 be
0.125000        00 00 00 3e
-0.125000       00 00 00 be
2.500000        00 00 20 40
-2.500000       00 00 20 c0
6.125000        00 00 c4 40
-6.125000       00 00 c4 c0
>>>

Simply reverse the order of the 4 bytes
then rotate left the first 9 bits

eg

   -8.0 is     00 00 00 c1

reverse the 4 bytes:

   C1 00 00 00

rotate left the first 9 bits

11000001 00000000 -> 10000010 10000000

so you get

   82 80 00 00  which is -8.0 in pic iee format

James

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...