• QWORD to double and vise-verse - checking overflow and loss of precision ?

    From R.Wieser@address@is.invalid to alt.lang.asm on Sat Jun 7 15:04:21 2025
    From Newsgroup: alt.lang.asm

    Hello all,

    Using a 32-bit hardware :

    Loading a 64-bit integer into the FPU, and than extract it as a double (fild,fstp). When the value is very large a loss-of-precision occurs (the lower bits get lost).

    Loading a double and storing it as a 64-bit integer (fld, fistp). When the value is very large an overflow occurs.

    As my FPU doesn't throw an exception (and I do not need it to), how do I
    check for the just-occurred loss-of-precision or overflow ?

    I've been looking at the FSTSW/FNSTSW instruction, but that doesn't show either of the above exceptions.

    I've tried DDG-ing for it, but could not find anything (other than
    suggestions to how not to get those exceptions). :-(

    Regards,
    Rudy Wieser


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.lang.asm on Sun Jun 8 11:38:01 2025
    From Newsgroup: alt.lang.asm


    As my FPU doesn't throw an exception (and I do not need it to), how
    do I check for the just-occurred loss-of-precision or overflow ?

    I just found what the answer.

    Although the fistp, fstp instructions mentioned throwing exceptions, I could not find the mentioned flags anywhere.

    That is, until I, while ddg-ing, stumbled over a webpage showing the
    bit-flags in the status word. Taking a hint from the used captions name I found the same table in my "The IA-32 Intel Architecture Software
    Developer's Manual, Volume 1 - Basic Architecture" documentation.

    Odd though, when testing what exeptions a way-too-big float would cause when trying to store it into a dword I got an "Invalid Operation", not an "Overflow" exception.

    Regards,
    Rudy Wieser


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rosario19@Ros@invalid.invalid to alt.lang.asm on Mon Jun 16 18:02:05 2025
    From Newsgroup: alt.lang.asm

    On Sat, 7 Jun 2025 15:04:21 +0200, "R.Wieser" wrote:
    Hello all,

    Using a 32-bit hardware :

    Loading a 64-bit integer into the FPU, and than extract it as a double >(fild,fstp). When the value is very large a loss-of-precision occurs (the >lower bits get lost).

    Loading a double and storing it as a 64-bit integer (fld, fistp). When the >value is very large an overflow occurs.

    As my FPU doesn't throw an exception (and I do not need it to), how do I >check for the just-occurred loss-of-precision or overflow ?

    I've been looking at the FSTSW/FNSTSW instruction, but that doesn't show >either of the above exceptions.

    I've tried DDG-ing for it, but could not find anything (other than >suggestions to how not to get those exceptions). :-(

    Regards,
    Rudy Wieser

    i see the subject in the follow way:
    if 64 number is a list of binary numbers, or 2 32 bits int numbers in
    memory, there is nothing that one miss
    if 64 bit number is ask as input, in decimal form (or something as
    long double 1.8968685675745464643;), yes some imprecision has to be in
    the last binary digits
    --- Synchronet 3.21d-Linux NewsLink 1.2