Ok I have two functions the first of which looks like so:
let dlth x = float (x.ToString().Length)
which takes a float and returns the number of digits, that part works fine. The second function looks like this:
let droot x = ((x ** (1./(dlth x))) % 1.)
which takes a float and raises it to a power equal to 1.0/(number of digits), then takes the result and does modulus 1.0. Which should be zero for a whole number.
so for droot 36. it takes (36.0 ** (1.0/2.0)) which is 6.0 then 6.0 mod 1.0 equals 0.0;
Now, that works fine right up to where I try the number 81.0. (and all numbers higher than 81 that should work) which returns 1.0 for some reason, throwing off my pattern matching. Can anybody tell me why this is happening?
PostScript: this is part of a Project Euler solution. If you know which problem, please DO NOT post the Project Euler solution. I just need help figuring out why the modulus is returning funny results