News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

FPU Unsigned Integers

Started by Lautrec_72, April 16, 2007, 03:16:44 PM

Previous topic - Next topic

Lautrec_72

Hi everybody, I was just wondering if there's a way to load and use an Unsiged Integer above 9,223,372,036,854,775,807 in the FPU with FILD or another instruction ?

I came to this when I was trying to load an Unsigned Integer value of 4,294,967,295 with FILD dword ptr[i32] but then I realized that it would load -1 Instead cause it is being treated as a Signed Integer; so I Zero-Extended 0FFFFFFFFh to 00000000FFFFFFFFh (64-bit Int) and now it loads 4,294,967,295.

I know 9,223,372,036,854,775,807 is about Exabytes, and that I won't be using that amount of data in some time  :dazzled: but if you got any idea ?.  :bdg

gabor

Hello!

I am afraid this is not possible. The FPU presents the numbers in float values anyway, so if you can store the number in real format it will work. (I don't know which real format will grant you the desired precision to use such a big number with so many digits.)

Other way is to use algos for extra large integers. You can search for such topics on the forums!

Greets, Gábor

dsouza123

9,223,372,036,854,775,807 == 2^63 -1 == 7FFFFFFFFFFFFFFFh == bit 63 cleared 0 and bits 62..0 set 1

The 80-bit extended precision floating point format can hold this max positive in a signed 64 bit value.
Some specific larger numbers may be able to be stored without loss of precision,
perhaps the powers of 2 but I haven't confirmed this with tests.


raymond

The FPU will only allow the loading of signed integers. As indicated by others, the largest positive one which can be loaded directly from memory as a QWORD with the FILD instruction is 9,223,372,036,854,775,807. A positive value up to twice that one could be loaded with extra instructions without loosing precision.

This doesn't mean that you cannot have much larger positive integers on the FPU. However, any positive integer which would require more than 64 bits will loose some precision. And, if it is larger than 63 bits, you would need some additional code to store it in memory as an integer (as opposed to using only the FIST instruction).

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com