I have this code in Java:
String pr = "4173df24c969ff63"
long prLongBits = Long.valueOf(pr, HEX_BASE).longValue();
prDoubleValue = Double.longBitsToDouble(prLongBits);
the result of: prDoubleValue = 2.083694058837832E7
How would i convert this in Objective C??
i tried to convert from hex to long and then long to double, but no proper result.
BR,
Suppi
I would try something like the following:
I haven’t tried it out but the basic idea should be approximately right. You want to convert the hex string to a bunch of bytes stored in a numeric data type of an appropriate size. Once that bit pattern is in memory we copy it into the memory assigned to a double.
This assumes that the string representation used to create the hex string used the same byte ordering as the one where your code is running.