Student Support Forum: 'A Bug?' topicStudent Support Forum > General > "A Bug?"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Nick 09/16/05 03:00am I found this bug (?) while writing a program. Lets say I execute the following line: Clear[f]; n = 3; Do[f[x] = x, {x, n + .4, n + .8, .2}]; f[n + .6] As you would expect, I get back 3.6 Now, when I execute the very similar line Clear[f]; n = 4; Do[f[x] = x, {x, n + .4, n + .8, .2}]; f[n + .6] I don't get back 4.6, I get back f[4.6]. If I ask for f[4.4] or f[4.8] I get the correct values, but for some reason f[4.6] doesn't assign. I can manually assign f[4.6], but it doesn't work in the Do loop. I did a loop to see which values of n (in the above line) has this problem, and they are: n=4 to 7, 64 to 127, 1024 to 2047 and so on, which I noticed had the pattern n=2^2 to 2^3-1, 2^6 to 2^7-1, 2^10 to 2^11-1 and so on. If I change the limits on the Do loop then it sometimes works, for example Clear[f]; n = 4; Do[f[x] = x, {x, n, n + .8, .2}]; f[n + .6] will return 4.6 as desired, whereas Clear[f]; n = 4; Do[f[x] = x, {x, n + .2, n + .8, .2}]; f[n + .6] returns f[4.6]. From what I can tell, only the n.6 value is affected, i.e. not n.4 or n.8 and such. I did these calculations on a clean kernel and a fresh install of Mathematica. Is this a bug? I am using Mathematica 5.2 on a 64-bit Linux system. Attachment: bug.nb, URL: ,

 Subject (listing for 'A Bug?') Author Date Posted A Bug? Nick 09/16/05 03:00am Re: A Bug? Marek 09/19/05 1:00pm Re: A Bug? yehuda ben-s... 09/19/05 2:57pm
 Next Comment > Help | Reply To Topic