[Haskell-cafe] Problems with truncate big float values in Haskell
Henson
jfsihenson at gmail.com
Thu Jan 5 18:16:57 UTC 2017
Hi,
Firstly I desire one year brilliant for all on group.
I have one simple problem but not solved for me for some mistake mine.
I have one Rational number (3 + sqrt 5) and I need get the last three
digits from
integral part of that number.
The question is the number is arbitrary and that number always is power
of n and n is between 2(Two) and 2000000000(Two billions).
I have attempted that on ghci for various values and get same result
with different powers:
let x = (truncate ((3 + sqrt 5) ^ 2000000)) `mod` 1000 and result is 216.
let y = (truncate ((3 + sqrt 5) ^ 20000000)) `mod` 1000 and result is 216.
let w = (truncate ((3 + sqrt 5) ^ 200000000)) `mod` 1000 and result is 216.
let z = (truncate ((3 + sqrt 5) ^ 2000000000)) `mod` 1000 and result is 216.
The result is same for all:
216, and is incorrect because any that expressions have one exclusive value.
What I do for complete that task correctly and what I'm mistaken here?!
Thank you,
Josenildo Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170105/c01e9c6f/attachment.html>
More information about the Haskell-Cafe
mailing list