Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > convert to little endian

Reply
Thread Tools

convert to little endian

 
 
mike
Guest
Posts: n/a
 
      10-20-2004
Trying to convert the following to little endian. I have set up my
long bits but dont know how to shift the bits correctly. Heres what I
have at the moment.

long lgn = 0;
long l = Double.doubleToLongBits(dbl);
for (int shift = 0; shift < 64; shift+=
{
lgn |= l & 0xff << shiftBy;
}
Any help would be great.
 
Reply With Quote
 
 
 
 
Thomas Fritsch
Guest
Posts: n/a
 
      10-20-2004
mike wrote:
> Trying to convert the following to little endian. I have set up my
> long bits but dont know how to shift the bits correctly. Heres what I
> have at the moment.

Convert to little-endian from what? From little-endian or from
big-endian? Currently your algorithm converts from little-endian to
little-endian; your end-result is simply lgn == l.
>
> long lgn = 0;
> long l = Double.doubleToLongBits(dbl);
> for (int shift = 0; shift < 64; shift+=
> {
> lgn |= l & 0xff << shiftBy;

You probably mean 'shift' here, not 'shiftby' which isn't declared.
Also: Please use parentheses here, to clarify what you intend.
lgn |= (l & 0xff) << shiftBy;
or lgn |= l & (0xff << shiftBy);
(Because the rules of precedence are easy to remember for compilers, but
hard for humans.)
> }
> Any help would be great.

Please refine your problem description! What do you want to achieve?

--
"Thomas:Fritsch$ops:de".replace(':','.').replace(' $','@')

 
Reply With Quote
 
 
 
 
hilz
Guest
Posts: n/a
 
      10-20-2004
> "Thomas:Fritsch$ops:de".replace(':','.').replace(' $','@')

nice!



 
Reply With Quote
 
Thomas G. Marshall
Guest
Posts: n/a
 
      10-21-2004
hilz coughed up:
>> "Thomas:Fritsch$ops:de".replace(':','.').replace(' $','@')

>
> nice!



What he said. That's kinda nifty.



--
Framsticks. 3D Artificial Life evolution. You can see the creatures
that evolve and how they interact, hunt, swim, etc. (Unaffiliated with
me). http://www.frams.alife.pl/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Little Endian to Big Endian invincible C++ 9 06-14-2005 10:21 PM
Little Endian to Big Endian for 32 bit invincible C++ 1 06-14-2005 04:20 PM
float: IEEE, big endian, little endian Ernst Murnleitner C++ 0 01-13-2004 01:48 PM
convert from BIG-ENDIAN to LITTLE-ENDIAN hicham C++ 2 07-02-2003 04:55 PM
convert from big-endian to little-endian hicham C Programming 0 06-30-2003 10:16 AM



Advertisments