From: linnix on
On Mar 24, 9:27 am, Bob <SkiBoy...(a)excite.com> wrote:
> linnix wrote:
> > On Mar 23, 12:35 pm, Hans-Bernhard Bröker <HBBroe...(a)t-online.de>
> > wrote:
>
> <snip>
>
>
>
> > It is mainly for storage. Unsigned char (8 bits) takes less space than
> > float (16 bits) or double (32 bits).  We don't really care how the
> > compiler does it, but storage is important for a 1K SRAM chip.
>
> Really? I've never run across a 16 bit float. Every compiler I've worked
> with uses 32 bits for float (sign, 8 bit exp, 23 bit mantissa w/ implied
> MSB) and 64 bits for double. It's been a long time since I read IEEE-754
> and it wouldn't surprise me that it allowed for other formats, I've just
> never seen them.
>
> Bob

Yes, my mistake. As you can see in the example, it transferred 4
bytes.

lds r24,f
lds r25,(f)+1
lds r26,(f)+2
lds r27,(f)+3
From: Grant Edwards on
On 2010-03-24, Bob <SkiBoyBob(a)excite.com> wrote:
> linnix wrote:
>> On Mar 23, 12:35 pm, Hans-Bernhard Br?ker <HBBroe...(a)t-online.de>
>> wrote:
>
><snip>
>
>>
>> It is mainly for storage. Unsigned char (8 bits) takes less space than
>> float (16 bits) or double (32 bits). We don't really care how the
>> compiler does it, but storage is important for a 1K SRAM chip.
>
> Really?

No, I don't think so.

> I've never run across a 16 bit float.

The last time I used avr-gcc a float was 32 bits. I seriously doubt
that's changed in the past year or two.

> Every compiler I've worked with uses 32 bits for float (sign, 8 bit
> exp, 23 bit mantissa w/ implied MSB) and 64 bits for double.

Gcc on some platforms has a option to make doubles 32 bits also.

> It's been a long time since I read IEEE-754 and it wouldn't surprise
> me that it allowed for other formats, I've just never seen them.

IIRC, it only specifies the two formats (32 bits and 64 bits).

--
Grant Edwards grant.b.edwards Yow! Your CHEEKS sit like
at twin NECTARINES above
gmail.com a MOUTH that knows no
BOUNDS --
From: Vladimir Vassilevsky on


Bob wrote:


> I've never run across a 16 bit float. Every compiler I've worked
> with uses 32 bits for float (sign, 8 bit exp, 23 bit mantissa w/ implied
> MSB) and 64 bits for double.

SHARC DSP from Analog Devices supports 16-bit float in the hardware; it
is supported by tools as well.

> It's been a long time since I read IEEE-754
> and it wouldn't surprise me that it allowed for other formats, I've just
> never seen them.

Me uses self made 24-bit float class (16 bit mantessa + 8 bit exponent)
routinely; it is very handy when you work with 8-bit or 16-bit integer
machine.


Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com

From: Hans-Bernhard Bröker on
Jamie wrote:
> linnix wrote:

>> It is mainly for storage. Unsigned char (8 bits) takes less space than
>> float (16 bits) or double (32 bits). We don't really care how the
>> compiler does it, but storage is important for a 1K SRAM chip.

> Last time I knew, that just cast the object into what you want, but it's
> not going to magically convert a FLOAT to a unsigned char..

Well, that only prove it's imperative that you get away from last time
you knew, into the real time we're in, and find better things to know.

You remember pretty much the opposite of the truth.

> Its only going to instruct the compiler that the contents of memory the
> "F" occupies is a unsigned char and simply moves the data from that
> from ever it is in memory to "u"

No. There's a statement involving a cast that would do that, but it's
_not_ the statement we've been discussing here.

> simply speaking..
> u = f; isn't the same as u = (unsigned char) f; where I come from..

Then you need to come from a different place.

> u = (unsigned char) f; simply tells the compiler to treat the object
> of "F" as if it was a char instead. No conversion is taking
> place here.

Wrong.

> As far as how the floats are implemented for the binary format of
> this compiler will dictate what value of data will be returned..

No, it won't. The platform's floating point format is almost always
irrelevant to the resulting value of this expression. Typically the
_only_ things relevant are the range of unsigned char, and the decision
made by the compiler implementor (or platform ABI) about what kind of
undefined behaviour to exhibit if the float's value is outside that range.
From: George Neuner on
On Wed, 24 Mar 2010 13:02:24 -0500, Vladimir Vassilevsky
<nospam(a)nowhere.com> wrote:

>Bob wrote:
>
>> I've never run across a 16 bit float. Every compiler I've worked
>> with uses 32 bits for float (sign, 8 bit exp, 23 bit mantissa w/ implied
>> MSB) and 64 bits for double.
>
>SHARC DSP from Analog Devices supports 16-bit float in the hardware; it
>is supported by tools as well.

Not exactly. The SHARC fpu operates on 32 or 40 bit data. A 16-bit
packed storage format is supported by the ISA using FPACK/FUNPACK
instructions which are special shifter operations.

The shifter can't access memory - only the register file - so you need
to load before unpacking and pack before storing. In the worst case -
an isolated operation on packed operands producing a packed result -
the (un)packing can add 80% overhead to the FPU operation. However,
because the SHARC is multiple issue and the shifter works in parallel
with the FPU, the overhead of (un)packing multiple values can be
amortized over longer FPU sequences.


>> It's been a long time since I read IEEE-754
>> and it wouldn't surprise me that it allowed for other formats, I've just
>> never seen them.

FWIW: IEEE 754-2008 now defines a standard 16-bit binary float format.
(see http://en.wikipedia.org/wiki/IEEE_754-2008)


>Me uses self made 24-bit float class (16 bit mantessa + 8 bit exponent)
> routinely; it is very handy when you work with 8-bit or 16-bit integer
>machine.

I recall some software FP libraries offering 16-bit floating point
operations back in the days when FP coprocessors were expensive
luxuries.

George
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9
Prev: NET tips to expand your biz
Next: IR is insane