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

    From R.Wieser@address@is.invalid to alt.lang.asm on Mon Jun 16 22:14:05 2025
    From Newsgroup: alt.lang.asm

    Rosario,

    if 64 number is a list of binary numbers, or 2 32 bits int
    numbers in memory, there is nothing that one miss

    The problem occurs when converting a (too big) 64-bit *float* into a 64-bit *integer*.

    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

    Thats also problem, but not as big as an the overflow described above.

    And than there is the loss-of-precision that can occur when a 64-bit
    *integer* is converted into a 64-bit *float*. If the integer has bits set above the 53-th bit than the float will not be able to exactly store that value (some of the integers lower bits will disappear).


    Though as my previous message mentions, I've been able to find that all of
    the above problems are caught caught and available in the FPU status word.

    Thanks for the reply though.

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • 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 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