I Need Help
- Posted by Larry D Poos <ldpoos at JUNO.COM> Jun 19, 1997
- 939 views
I was messing about with some code that extracts a number from another number using the difference between a calculated real number and its integer. I could not seem to get the expected answer. I then wrote a bit of test code to see just what Euphoria was doing and I don't get the result I expected either. I am not sure (being new to Euphoria) if it is something I don't understand about how the language works or if it is something else. I would appreciate any help I could get in understanding Why the code included dose not give me the results I expected. Larry D. Poos -[USMC (Retar{bks}{bks}ired) Havelock, NC]- - Programming and System Consultant, LTAD Enterprises - e-mail: ldpoos at juno.com Fido: 1:3629/101.6 -- Begin code segment -- Example of math problem -- by Larry Poos -- Thu 06-19-1997 -- 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}) z = remainder(10,7) printf(1,"\nmodulo test 2\n %s for 10mod7=%d\n",{bool[z=3],z}) printf(1,"\nequality test %s\n",{bool[remainder(3,7)=remainder(10,7)]}) -- other tests -- 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") 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 puts(1,"Fail for all between 0 and 10000 not listed\n") 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