Answer the question
In order to leave comments, you need to log in
How does variable and ByteOrder initialization work in golang?
Good day, I would like to get an explanation for this example: var num int32 = 0x00000020
My machine is running on litle-endian, and with this notation, the number num1 = 5.......... , but the output I get is 32 , and when I look this number is in memory, I see 0x20000000 .
So, why, with such a record of a number, does it reverse the data? It seems that with this initialization of the variable, the data is received in big-endian , and then transferred to the machine order.
I don't have the opportunity to test the code on a big-endian processor, but support for such a processor is needed.
Immediately the second question on the topic, as always reading from the stream, and then when writing to the stream, write the numbers in orderbig-endian regardless of processor order, i.e. if the processor works in big , then write it as it is, and if it works in litle, then convert it?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question