MySQL Forums
Forum List  »  GIS

Re: wkb endian usage?
Posted by: Ulf Küßner
Date: October 21, 2005 11:26AM

Hi Francesco,
I noted my error after the post, but I thought as long as I don't point at it, noone else would ;) In fact, the first bit was ignored in mysql, but a patch is pending/ commited for it.

In Java5, you can simply use the Long, Double wrapper classes to get a hex representation of the rsp. decimal value.
with Long.reverseBytes(long i) you can reverse the bytes.

try this:

// Little Endian representation on 1.0
Long little_endian_one = 0x000000000000F03FL;
// convert to big endian
Long conv_endian = Long.reverseBytes(little_endian_one);
System.out.println("converted to big Endian:" + Long.toString(conv_endian, 16));
// print a double representation
System.out.println("with endian conversion:" + Double.longBitsToDouble(conv_endian));
System.out.println("without endian conversion:" + Double.longBitsToDouble(little_endian_one));

it should output
converted to big Endian:3ff0000000000000
with endian conversion:1.0
without endian conversion:3.03865E-319

Options: ReplyQuote


Subject
Views
Written By
Posted
4894
August 26, 2005 05:02AM
3197
October 09, 2005 06:07PM
Re: wkb endian usage?
3702
October 21, 2005 11:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.