EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Floating point numbers and endian ness??

Started by ssubbarayan April 25, 2008
Hi,
I was going through wikipedia about endians.I got the below
description with respect to floating point numbers:
"On some machines, while integers were represented in little-endian
form, floating-point numbers were represented in big-endian form. [3]
Because there are many floating formats, and a lack of a standard
"network" representation, no standard for transferring floating point
values has been made. This means that floating point data written on
one machine may not be readable on another, and this is the case even
if both use IEEE 754 floating point arithmetic since the endian-ness
of the memory representation is not part of the IEEE specification"

Why is it so?How do people who need to work with floating point math
manage when their application involves communication between two cpus
of different endians?



Regards,
s.subbarayan
Op Fri, 25 Apr 2008 13:56:36 +0200 schreef ssubbarayan <ssubba@gmail.com>:
> I was going through wikipedia about endians.I got the below > description with respect to floating point numbers: > "On some machines, while integers were represented in little-endian > form, floating-point numbers were represented in big-endian form. [3] > Because there are many floating formats, and a lack of a standard > "network" representation, no standard for transferring floating point > values has been made. This means that floating point data written on > one machine may not be readable on another, and this is the case even > if both use IEEE 754 floating point arithmetic since the endian-ness > of the memory representation is not part of the IEEE specification" > > Why is it so?How do people who need to work with floating point math > manage when their application involves communication between two cpus > of different endians?
By dealing with that on the application level. Most programming languages and CPU's allow you to split the binary representation of the number into octects (bytes) and to transfer them in any order. -- Gemaakt met Opera's revolutionaire e-mailprogramma: http://www.opera.com/mail/
ssubbarayan schrieb:

> Why is it so?How do people who need to work with floating point math > manage when their application involves communication between two cpus > of different endians?
As far as I know the recommended way is to split the float-number into exponent and mantissa and transfer these using the native endianess. For the C-language there is a function to do the decomposition defined in math.h I think. I don't remember it's name because I never had a reason to call it though. Nils
ssubbarayan wrote:
> How do people who need to work with floating point math > manage when their application involves communication between two cpus > of different endians?
They work by defining the format of the data they are sending and encoding / decoding appropriately. Using ASN.1 BER encoding is one way, but simply defining the floating point format and byte order will work. Another option is conversion to a decimal floating point string. -- Thad
On Fri, 25 Apr 2008 04:56:36 -0700 (PDT), ssubbarayan
<ssubba@gmail.com> wrote:

>Hi, >I was going through wikipedia about endians.I got the below >description with respect to floating point numbers: >"On some machines, while integers were represented in little-endian >form, floating-point numbers were represented in big-endian form. [3] >Because there are many floating formats, and a lack of a standard >"network" representation, no standard for transferring floating point >values has been made. This means that floating point data written on >one machine may not be readable on another, and this is the case even >if both use IEEE 754 floating point arithmetic since the endian-ness >of the memory representation is not part of the IEEE specification" > >Why is it so?How do people who need to work with floating point math >manage when their application involves communication between two cpus >of different endians?
In the days of hundreds different floating point representations and the only means of communication between computers from different manufacturers was the 1/2 inch ANSI labeled tape, the floating point values were usually simply converted to ASCII (or EBCDIC) characters. You may loose one or two bits of precession, this was not an issue at least for double precession. While IEEE 754 simplified things a lot, the ASCII numeric transfer is still a viable option, especially if all partners in a communication systems are not well informed about endianess and bit representation issues. Paul
On Apr 25, 7:56 am, ssubbarayan <ssu...@gmail.com> wrote:
> Hi, > I was going through wikipedia about endians.I got the below > description with respect to floating point numbers: > "On some machines, while integers were represented in little-endian > form, floating-point numbers were represented in big-endian form. [3] > Because there are many floating formats, and a lack of a standard > "network" representation, no standard for transferring floating point > values has been made. This means that floating point data written on > one machine may not be readable on another, and this is the case even > if both use IEEE 754 floating point arithmetic since the endian-ness > of the memory representation is not part of the IEEE specification" > > Why is it so?How do people who need to work with floating point math > manage when their application involves communication between two cpus > of different endians?
Are you aware that the "endianess" of a processor only matters when it is accessing larger quantities using smaller transfers, e.g. reading a 32 bit word one byte at a time. If you are accessing words, you don't care how the processor would access it as bytes, because that is not happening. So if you transmit the words as words and not bytes, you won't care about the endiannss of the processors. Rick
In article <cc92c027-c9c8-4404-b8b4-
a795649089ac@l42g2000hsc.googlegroups.com>, rickman says...
> On Apr 25, 7:56 am, ssubbarayan <ssu...@gmail.com> wrote: > > Hi, > > I was going through wikipedia about endians.I got the below > > description with respect to floating point numbers: > > "On some machines, while integers were represented in little-endian > > form, floating-point numbers were represented in big-endian form. [3] > > Because there are many floating formats, and a lack of a standard > > "network" representation, no standard for transferring floating point > > values has been made. This means that floating point data written on > > one machine may not be readable on another, and this is the case even > > if both use IEEE 754 floating point arithmetic since the endian-ness > > of the memory representation is not part of the IEEE specification" > > > > Why is it so?How do people who need to work with floating point math > > manage when their application involves communication between two cpus > > of different endians? > > Are you aware that the "endianess" of a processor only matters when it > is accessing larger quantities using smaller transfers, e.g. reading a > 32 bit word one byte at a time. If you are accessing words, you don't > care how the processor would access it as bytes, because that is not > happening. So if you transmit the words as words and not bytes, you > won't care about the endiannss of the processors.
Other than common memory are there any transfer mechanisms that son't use a byte or smaller as their organization across a communications channel? Robert ** Posted from http://www.teranews.com **
Op Sat, 26 Apr 2008 08:32:42 +0200 schreef Paul Keinanen <keinanen@sci.fi>:
> On Fri, 25 Apr 2008 04:56:36 -0700 (PDT), ssubbarayan > <ssubba@gmail.com> wrote: > > You may loose one or two bits of precession, this was not an issue at > least for double precession.
http://en.wikipedia.org/wiki/Precession -- Gemaakt met Opera's revolutionaire e-mailprogramma: http://www.opera.com/mail/
On Apr 26, 8:07 pm, Robert Adsett <s...@aeolusdevelopment.com> wrote:
> In article <cc92c027-c9c8-4404-b8b4- > a79564908...@l42g2000hsc.googlegroups.com>, rickman says... > > > > > On Apr 25, 7:56 am, ssubbarayan <ssu...@gmail.com> wrote: > > > Hi, > > > I was going through wikipedia about endians.I got the below > > > description with respect to floating point numbers: > > > "On some machines, while integers were represented in little-endian > > > form, floating-point numbers were represented in big-endian form. [3] > > > Because there are many floating formats, and a lack of a standard > > > "network" representation, no standard for transferring floating point > > > values has been made. This means that floating point data written on > > > one machine may not be readable on another, and this is the case even > > > if both use IEEE 754 floating point arithmetic since the endian-ness > > > of the memory representation is not part of the IEEE specification" > > > > Why is it so?How do people who need to work with floating point math > > > manage when their application involves communication between two cpus > > > of different endians? > > > Are you aware that the "endianess" of a processor only matters when it > > is accessing larger quantities using smaller transfers, e.g. reading a > > 32 bit word one byte at a time. If you are accessing words, you don't > > care how the processor would access it as bytes, because that is not > > happening. So if you transmit the words as words and not bytes, you > > won't care about the endiannss of the processors. > > Other than common memory are there any transfer mechanisms that son't > use a byte or smaller as their organization across a communications > channel?
What comms was the OP using? Regardless, endianess is still not an issue with byte oriented protocols as long as you don't use byte memory accesses. Read the full word and break it into bytes yourself. Then send the bytes in an order agreed to as part of the protocol. If the protocol doesn't specify byte order, then you are not using the right protocol. If you are depending on the machine or the compiler to decide what order the bytes are, then you are not doing a good job of programming.
In article <4eb60be1-7337-48f9-9ee4-
a09b0cd6b89a@m44g2000hsc.googlegroups.com>, rickman says...
> On Apr 26, 8:07 pm, Robert Adsett <s...@aeolusdevelopment.com> wrote: > > In article <cc92c027-c9c8-4404-b8b4- > > a79564908...@l42g2000hsc.googlegroups.com>, rickman says... > > > > > > > > > On Apr 25, 7:56 am, ssubbarayan <ssu...@gmail.com> wrote: > > > > Hi, > > > > I was going through wikipedia about endians.I got the below > > > > description with respect to floating point numbers: > > > > "On some machines, while integers were represented in little-endian > > > > form, floating-point numbers were represented in big-endian form. [3] > > > > Because there are many floating formats, and a lack of a standard > > > > "network" representation, no standard for transferring floating point > > > > values has been made. This means that floating point data written on > > > > one machine may not be readable on another, and this is the case even > > > > if both use IEEE 754 floating point arithmetic since the endian-ness > > > > of the memory representation is not part of the IEEE specification" > > > > > > Why is it so?How do people who need to work with floating point math > > > > manage when their application involves communication between two cpus > > > > of different endians? > > > > > Are you aware that the "endianess" of a processor only matters when it > > > is accessing larger quantities using smaller transfers, e.g. reading a > > > 32 bit word one byte at a time. If you are accessing words, you don't > > > care how the processor would access it as bytes, because that is not > > > happening. So if you transmit the words as words and not bytes, you > > > won't care about the endiannss of the processors. > > > > Other than common memory are there any transfer mechanisms that son't > > use a byte or smaller as their organization across a communications > > channel? > > What comms was the OP using? Regardless, endianess is still not an > issue with byte oriented protocols as long as you don't use byte > memory accesses.
How do you have a byte oriented protocol w/o using byte accesses?
> Read the full word and break it into bytes > yourself. Then send the bytes in an order agreed to as part of the > protocol. If the protocol doesn't specify byte order, then you are > not using the right protocol. If you are depending on the machine or > the compiler to decide what order the bytes are, then you are not > doing a good job of programming.
Absolutely. But endianess does matter across the wire (and it may show up on the CPU side as well). And when receiving do the reverse taking care of the endianess on the wire. Robert ** Posted from http://www.teranews.com **

Memfault Beyond the Launch