I ask because I am computing matrix multiplications where all the matrix values are integers.
I'd like to use LAPACK so that I get fast code that is correct. Will two large integers (whose product is less than 2^53
), stored as double
s, when multiplied, yield a double
containing the exact integer result?
Your analysis is correct:
Hence a product of two values that equals an integer in that range will therefore be represented exactly.
Reference: What every computer scientist should know about floating-point arithmetic. The key section is the discussion of the IEEE standard as pertaining to operations. That contains the statement of the second bullet point above. You already knew the first bullet point and it's the second point that completes the argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With