Float to Bytes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Float to Bytes

Lee Sylvester
Hey guys,

Does anyone know how to convert a float to bytes?  Little endian if
poss, please :-)

Thanks,
Lee



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Float to Bytes

Nicolas Cannasse
Lee McColl Sylvester a écrit :
> Hey guys,
>
> Does anyone know how to convert a float to bytes?  Little endian if
> poss, please :-)

Use an haxe.io.BytesOutput then use either writeFloat() or writeDouble()
after setting the output endianness.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Float to Bytes

Daniel Turing
In reply to this post by Lee Sylvester
Lee,

On Wed, 2008-10-29 at 16:44 +0000, Lee McColl Sylvester wrote:
> Does anyone know how to convert a float to bytes?  Little endian if
> poss, please :-)

AFAIK, floats have no endian issues. (surely they can have different
formats though).

In any case, you'd probably use a ByteOutput and writeFloat/writeDouble.

-dan



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Float to Bytes

Lee Sylvester
Thanks Dan and Nicolas for that one. I knew there was a way, but
couldn't locate it. I had been looking in the Neko package. I'd
forgotten it had moved ;-)

Lee





Daniel Turing wrote:

> Lee,
>
> On Wed, 2008-10-29 at 16:44 +0000, Lee McColl Sylvester wrote:
>  
>> Does anyone know how to convert a float to bytes?  Little endian if
>> poss, please :-)
>>    
>
> AFAIK, floats have no endian issues. (surely they can have different
> formats though).
>
> In any case, you'd probably use a ByteOutput and writeFloat/writeDouble.
>
> -dan
>
>
>
>  


--
haXe - an open source web programming language
http://haxe.org