Reputation: 43
I need to parse a byte array to find latitude and longitude.
I have four bytes {0x91,0x2a,0xb4,0x41}
that I use to calculate the latitude.
The response should be 22.52078
.
How can I find the result ? I use C# to do the parse.
Upvotes: 3
Views: 1182
Reputation: 51430
Looks like a float
(4 bytes)...
var data = new byte[] { 0x91, 0x2a, 0xb4, 0x41 };
var coord = BitConverter.ToSingle(data, 0);
Console.WriteLine(coord); // Output is 22.52078
Demo.
Don't confuse float
/double
/decimal
:
Compared to floating-point types, the
decimal
type has more precision and a smaller range, which makes it appropriate for financial and monetary calculations.
double
(and float
to a lesser extent) are a better fit for physical measures.
Upvotes: 4