big endian vs little endian

i work on a 64 bit intel processor...i was learning about big and little endian and what i understood was that these are byte orderings within a word such that in a 64 bit data, msb will have lowest address in big endian form and the highest address in little endian i have a problem:

I wrote this code to determine whether my processor was little or big endian... I input

0102030405060708 (this is in hex) 

and hoped to get 08 and 07 and 06 and... and 01 as answer

but instead got 0 and 25 and 50 and -125 and -13 and 501 and -41 and 66. when I wrote the same code taking 's' as 2 byte(short), the output for 0102 was 2 and 1 (which is in accordance with little endian) what went wrong here?


You are storing your input value as a double, which stores the value as a floating point value. Try using a long long instead, which is a 64 bit integer, and should store the value as you expect.

Taking a hex number into a (double) is not likely to do what you expect; it's a floating point value consisting of a base 2 mantissa and exponent. You might find (long) or (long long) to be closer to what you intended.

Need Your Help

UILabel with text of two different colors

ios objective-c swift uilabel textcolor

I want to display a string like this in a UILabel:

Setting ISO-8859-1 encoding for a single Tapestry 4 page in application that is otherwise totally UTF-8

java encoding utf-8 tapestry iso-8859-1

I have a Tapestry application that is serving its page as UTF-8. That is, server responses have header: