1. Re: I Need Help - BUG REPORT!
- Posted by Daniel Berstein <architek at GEOCITIES.COM>
Jun 19, 1997
-
Last edited Jun 20, 1997
Larry D Poos wrote:
> atom x,z
> sequence bool
> bool = {"Fail","Pass"}
>
> -- modulo congruence test
> x = remainder(3,7)
> printf(1,"\nmodulo test 1\n %s for 3mod7=%d\n",{bool[x=3],x})
Why do you assign x=3?
"bool" has only a length of 2, and second you can't assign
there (it's not like C).
Maybe you could use something like this:
correct_answer = 3
x = remainder(3,7)
y = 1
if x = correct_answer then
y = 2
end if
printf(1, "\nmodulo test 1\n %s for 3mod7=%d\n", {bool[y+1],x})
> -- All numbers ending in .0 should display on screen
> -- only 0, 19, and 4819 display in all three forms of the alogrithm
> --
> puts(1,"\nDivision by 1 test\n")
> for l=0 to 10000 by .1 do
> if not remainder(l,1) then -- handle only if evenly divisable by 1
> printf(1," pass for %g floor=%g\n",{l,floor(l)})
> end if
> end for
> puts(1,"Fail for all between 0 and 10000 not listed\n")
***************************************************************************
Mmhhh.... I don't know why only 0,19 and 4819 divided by 1 have a
remainder of 1 ?! I guess it's a BUG!!! Let's Rob Craig answers this
one.
***************************************************************************
> puts(1,"\nFloor equality test\n")
> for l=0 to 10000 by .1 do
> if floor(l)=l then -- handle only if floor is equal to base number
> printf(1," pass for %e floor=%e\n",{l,floor(l)})
> end if
> end for
floor(l) = 1 only for "l" being between 1 and 1.99999. floor(x) returns
the bigest integer that is smaller than "x".
> puts(1,"\nNumber equality test\n")
> x=0
> while x < 10000.1 do
> z=floor(x)
> if not(z!=x) then -- handle only if equal
> printf(1," pass for %e floor=%e\n",{x,floor(x)})
> end if
> x=x+.1
> end while
> puts(1,"Fail for all between 0 and 10000 not listed\n")
> -- end code segment
You could test like this:
x = 0
while x < 10000.1 do
if floor(x) = x then
printf(1, "pass for %e floor=%e\n", {x, floor(x)})
end if
x = x + .1
end while
--
Regards,
Daniel Berstein
architek at geocities.com
http://www.geocities.com/SiliconValley/Heights/9316