If we are keeping score, R does too. :)

I am thinking about how to get around it when I want to know whether a 
number is some prime to some power. Like in here like n=2^j. An obvious way 
for me in here is using modulo, but with high values of j, it won't work. 
Any suggestion?

On Sunday, 29 June 2014 21:42:01 UTC+2, Mauro wrote:
>
> > So a bug? 
>
> Probably not a bug but an intrinsic limitation of floating point 
> numbers.   
>
> Python does the same: 
> >>> from math import * 
> >>> log(32768)%log(2) 
> 0.6931471805599452 
>
> (Although Matlab gets it "right".) 
>
> > On Saturday, 28 June 2014 13:59:22 UTC+2, Mauro wrote: 
> >> 
> >> I think that is a rounding issue.  log(2)==0.693... Presumably it 
> >> can't quite fit log(2) 15x into log(32768), thus it returns a reminder 
> >> which is almost log(2): 
> >> 
> >> julia> rem(a,b)-log(2) 
> >> -1.1102230246251565e-16 
> >> 
> >> which is around machine precision: 
> >> 
> >> julia> eps(1.0) 
> >> 2.220446049250313e-16 
> >> 
> >> On Sat, 2014-06-28 at 10:40, [email protected] <javascript:> wrote: 
> >> > When using the rem() function, I found out a mysterious thing. (Maybe 
> >> only 
> >> > my ignorance, hard to tell.) The log(32768)/log(2) gives 15.0, but 
> >> > rem(log(32768),log(2)) gives 0.693... How so? 
> >> 
> >> 
>
>

Reply via email to