I'm reverse engineering an application which commonly adds 4.294967296e9 to a double if the number is negative. Part of the disassembly:

mov     eax, label_to_memory
fild    label_to_memory
test    eax, eax
jge     short some_label
fadd    ds:some_double_value

If I'm correct, it takes the jump if the highest bit isn't set, i.e. its a positive number. some_double_value points to the constant 4.294967296e9.

To understand what the piece of code is doing I need to know why it adds this specific number, the only piece of Information I found was a line of code in http://web.mit.edu/~mkgray/afs/bar/afs/net/project/attic/quipu/isode-8.0/others/ntp/ntpsubs.c which says

    if (b < 0.0) b += 4.294967296e9;

So, what is the significance of that number?

Additional Info: The number can not be negative, so this can actually never happen.

1 Answer 1


I actually found the answer while writing this question!

This number is exactly UINT_MAX + 1, stored as a double. So it seems this code converts a unsigned integer to a double. The fild instruction loads the 32 bit value as signed value, after adding the max possible unsigned value + 1, the double contains the same value as the unsigned integer.

So the compiler produced this probably automatically from something like this:

unsigned int num; // some arbitrary 32 bit unsigned number
double d = num;

Since it took me some time to figure it out, I thought it may help someone else find the solution faster than me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.