Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #23561
| From | Vincent vB <embedded@spam.com> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: Integer/Fixedpoint to 32 bit float |
| Date | 2016-04-07 09:07 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ne50ub$1glj$5@gioia.aioe.org> (permalink) |
| References | <ne3289$f5a$1@gioia.aioe.org> <NPCdneAzmdhj5JjKnZ2dnUU7-amdnZ2d@giganews.com> <ne3uit$po1$1@dont-email.me> <ne3v5q$roa$1@dont-email.me> <57059a91$0$11965$c3e8da3$3a1a2348@news.astraweb.com> |
On 7-4-2016 at 1:23, Clifford Heath wrote:
> gcc has "int __builtin_clz (unsigned int x)", lso long and long-long
> versions. These map to whatever is most efficient for your hardware.
>
> It's a pity that there's no integer equivalent of ldexp; maybe called
> ldiexp.
>
> To the OP: If your endian-ness and compiler bit-fields work out, you
> can use this (works for me on x64 with gcc) for building and breaking
> float values.
>
> typedef union {
> float f;
> struct {
> uint32_t mantissa:23;
> uint32_t exponent:8;
> uint32_t sign:1;
> };
> } FloatU;
>
> Note that building a floating point value like this is likely to
> be slower than just saying "(float)l" - with any decent compiler.
> But it will help you understand what's going on.
>
> Clifford Heath.
Well, its not really a microcontroller. It is a LatticeMico 32 on a
Xilinx FPGA. I think its a big-endian processor, so this may work out.
I've tried doing the (float)l, but then the LM32 compiler really
attempts to convert the integer into a float. Horrible tricks like this
would work (except for the compiler screaming 'murder and fire' as we
say in Dutch):
uint32_t l = ...;
float f;
*f = (float*)&l;
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-06 15:17 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-06 17:16 +0300
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-06 17:21 +0300
Re: Integer/Fixedpoint to 32 bit float Grant Edwards <invalid@invalid.invalid> - 2016-04-06 14:40 +0000
Re: Integer/Fixedpoint to 32 bit float Dave Nadler <drn@nadler.com> - 2016-04-06 08:21 -0700
Re: Integer/Fixedpoint to 32 bit float Robert Wessel <robertwessel2@yahoo.com> - 2016-04-06 12:33 -0500
Re: Integer/Fixedpoint to 32 bit float Robert Wessel <robertwessel2@yahoo.com> - 2016-04-06 12:36 -0500
Re: Integer/Fixedpoint to 32 bit float Grant Edwards <invalid@invalid.invalid> - 2016-04-06 17:56 +0000
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-06 22:45 +0300
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 09:06 +0200
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 11:26 +0200
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 11:29 +0200
Re: Integer/Fixedpoint to 32 bit float Wouter van Ooijen <wouter@voti.nl> - 2016-04-06 18:00 +0200
Re: Integer/Fixedpoint to 32 bit float Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2016-04-06 21:35 +0300
Re: Integer/Fixedpoint to 32 bit float Grant Edwards <invalid@invalid.invalid> - 2016-04-06 18:47 +0000
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 08:52 +0200
Re: Integer/Fixedpoint to 32 bit float Tim Wescott <seemywebsite@myfooter.really> - 2016-04-06 16:05 -0500
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 00:23 +0300
Re: Integer/Fixedpoint to 32 bit float Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-06 21:30 +0000
Re: Integer/Fixedpoint to 32 bit float Clifford Heath <no.spam@please.net> - 2016-04-07 09:23 +1000
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 09:07 +0200
Re: Integer/Fixedpoint to 32 bit float Tim Wescott <tim@seemywebsite.com> - 2016-04-07 11:14 -0500
Re: Integer/Fixedpoint to 32 bit float Tim Wescott <seemywebsite@myfooter.really> - 2016-04-06 18:36 -0500
Re: Integer/Fixedpoint to 32 bit float lasselangwadtchristensen@gmail.com - 2016-04-06 17:03 -0700
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 09:04 +0200
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 10:21 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 11:28 +0300
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 10:41 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 11:47 +0300
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 11:40 +0200
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 12:50 +0200
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 13:52 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 22:14 +0300
Re: Integer/Fixedpoint to 32 bit float Nobody <nobody@nowhere.invalid> - 2016-04-08 03:39 +0100
csiph-web