<div class="gmail_quote">On Thu, Jul 14, 2011 at 9:02 AM, Jonathan M Davis <span dir="ltr"><<a href="mailto:jmdavisProg@gmx.com">jmdavisProg@gmx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:<br>
> On 7/14/11 5:51 AM, Regan Heath wrote:<br>
> > That's my point. I need 8/16/32/64/128 bit versions and it really would<br>
> > be better if there were general variants. My version are less than<br>
> > optimal, but do use intrinsics where possible. Someone else can do a far<br>
> > better job than I, and it really should be done once, by that person.<br>
> > Surely we have the infrastructure for someone to add this to phobos? If<br>
> > something this simple can't or won't be done, what hope do we have!?<br>
><br>
> I think we should have these functions in std.bitmanip:<br>
><br>
> T toBigEndian(T)(T val) if (isArithmetic!T || isSomeChar!T);<br>
> T toLittleEndian(T)(T val) if (isArithmetic!T || isSomeChar!T);<br>
> T bigEndianToNative(T)(T val) if (isArithmetic!T || isSomeChar!T);<br>
> T littleEndianToNative(T)(T val) if (isArithmetic!T || isSomeChar!T);<br>
><br>
> That means all characters, all integers, and all floating point numbers.<br>
> The implementations would opportunistically use intrinsics and other<br>
> specialized means.<br>
<br>
</div>Well, it's questionable as to whether there's any point in having such<br>
functions for 8-bit values, since it would just return the original value. And<br>
I don't think that it should deal with floating point numbers, since they're<br>
not affected by endian-ness.<br></blockquote><div><br></div><div>I looked this up at one point, and found that (according to Wikipedia, which may not be perfect) floating point numbers are generally stored according to the same endianness rules as integers, in which case they would be affected. I'm not an expert, but why do you think they aren't?</div>

</div><br>