EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Deal with big-endian and little-endian order


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html

JAVA virtual machine always used big-endian, Intel x86 used little-endian.


 public class Swab {
   public final static int swabInt(int v) {
     return  (v >>> 24) | (v << 24) | 
       ((v << 8) & 0x00FF0000) | ((v >> 8) & 0x0000FF00);
     }

   public static void main(String argv[]) {
     //  before 0x01020304
     //    after  0x04030201
     int v = 0x01020304;
     System.out.println("before : 0x" + Integer.toString(v,16));
     System.out.println("after  : 0x" + Integer.toString(swabInt(v),16));
     }
   }
   

Posted On: 3-Jul-1999

internet.commerce



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy