Expand Messages
• ... Hello! I come back to this subject. As you suggested, I have written this little program: t0 = timer for i% = 0 to 300 for j% = 0 to 300 for k% = 0 to 300
Message 1 of 4 , Feb 11, 2012
--- In chipmunkbasicforum@yahoogroups.com, "Gary" <gwmorris@...> wrote:
>
> You know, I never really thought of that before! I personally wouldn't think it would make any difference, but I would try it first with something that gets the variables changed a lot, maybe a search algorithm or something. Even just a counter might do it, or a program that switches vars into other ones or something. Shouldn't take long to write!
>
Hello!
I come back to this subject.
As you suggested, I have written this little program:

t0 = timer
for i% = 0 to 300
for j% = 0 to 300
for k% = 0 to 300
x% = i% + j% + k%
x% = x% mod 100
next k%
next j%
next i%
t1 = timer
print "Duration: "; t1 - t0; " s"

On my Mac, the duration is 9.53 s.
With the same program, written without the %s, the duration is 7.46 s.
So the %s bring no improvement: on the contrary, they slow down the computation a bit.
Moreover, I have made this test:

x% = 5.7
print x%
x% = 7/2
print x%
x% = 9/3
print x%
x% = 1.75
print x%

The printed results are 6, 4, 3 and 2.
Although the third one happens to be correct, the others are meaningless. One might have expected an error message about the data not being an integer, but there is no such thing. Another action could have been to reduce the data to its integer part, but this does not happen either.
Summarizing this, one could say that the % notation has no effect and is of no use, except as a reminder that one is thinking of integers.

Cheers.

Charles
• ... I was going to try it here, but then I remembered that I just upgraded to Fedora v16 and have yet to install basic. One thing I m wondering about, you say
Message 2 of 4 , Feb 11, 2012
--- In chipmunkbasicforum@yahoogroups.com, RenÃ© <charles.trois@...> wrote:
>
>
>
> --- In chipmunkbasicforum@yahoogroups.com, "Gary" <gwmorris@> wrote:
> >
> > You know, I never really thought of that before! I personally wouldn't think it would make any difference, but I would try it first with something that gets the variables changed a lot, maybe a search algorithm or something. Even just a counter might do it, or a program that switches vars into other ones or something. Shouldn't take long to write!
> >
> Hello!
> I come back to this subject.
> As you suggested, I have written this little program:
>
> t0 = timer
> for i% = 0 to 300
> for j% = 0 to 300
> for k% = 0 to 300
> x% = i% + j% + k%
> x% = x% mod 100
> next k%
> next j%
> next i%
> t1 = timer
> print "Duration: "; t1 - t0; " s"
>
> On my Mac, the duration is 9.53 s.
> With the same program, written without the %s, the duration is 7.46 s.
> So the %s bring no improvement: on the contrary, they slow down the computation a bit.
> Moreover, I have made this test:
>
> x% = 5.7
> print x%
> x% = 7/2
> print x%
> x% = 9/3
> print x%
> x% = 1.75
> print x%
>
> The printed results are 6, 4, 3 and 2.
> Although the third one happens to be correct, the others are meaningless. One might have expected an error message about the data not being an integer, but there is no such thing. Another action could have been to reduce the data to its integer part, but this does not happen either.
> Summarizing this, one could say that the % notation has no effect and is of no use, except as a reminder that one is thinking of integers.
>
> Cheers.
>
> Charles
>

I was going to try it here, but then I remembered that I just upgraded to Fedora v16 and have yet to install basic. One thing I'm wondering about, you say that only the third one is "correct", but the others ARE converting to int and seem to round properly. Personally, I would expect that to be the case.
Your message has been successfully submitted and would be delivered to recipients shortly.