Page 1 of 1

Syntax question?

Posted: Thu Feb 22, 2007 7:52 pm
by turshija
I wanted to know how to use modulation ? in most of programming languages its MOD or % but doesn't work in ZGE...

10 mod 5 = 0
10 % 5 = 0
12 % 5 = 2

i need it now :)

Posted: Fri Feb 23, 2007 12:57 pm
by VilleK
You can use frac-funtion which returns the decimal part.

frac(10.5) = 0.5
frac(10) = 0.0

Temp1=12/5; //2.4
Temp2=Temp1-frac(Temp1); //2.0
Temp1=Temp1*5 - Temp2*5; //2.0

Temp1 now has the mod-value.

Maybe if you tell me what you want to do then I can suggest an
easier variant?

I will add a mod-function in a later version.

Re: Syntax question?

Posted: Fri Feb 23, 2007 9:04 pm
by beldus
turshija wrote:I wanted to know how to use modulation ? in most of programming languages its MOD or % but doesn't work in ZGE...

10 mod 5 = 0
10 % 5 = 0
12 % 5 = 2

i need it now :)
I'm not totally up to date with the syntax in ZGE but couldn't you do?

modvalue =frac(X/Y)*Y

Where from your example x=10 and y=5

Re: Syntax question?

Posted: Sat Feb 24, 2007 10:12 am
by VilleK
beldus wrote: modvalue =frac(X/Y)*Y

Where from your example x=10 and y=5
Ah, clever!

I knew there must be a simpler solution then what I suggested.

Re: Syntax question?

Posted: Sat Feb 24, 2007 10:34 am
by turshija
beldus wrote: modvalue =frac(X/Y)*Y

Where from your example x=10 and y=5
nice ...

I'm happy there are more people online because there are more ideas :)

Thanks ...