Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with modulus!!!

Status
Not open for further replies.

sergelaurent

Technical User
May 30, 2005
52
0
0
FR
For exemple;
set toto [expr 5 - 10]

toto's value would be -5!!!

I want to have the modulus of toto!!!

Can someone tell me hos I can do this?
 
The modulus function has to do with remainders. It is, therefore, related to division, not subtraction. Tcl has a modulus function, if that is what you want.
fmod(x, y)
Returns the floating-point remainder of the division of x by y. If y is 0, an error is returned.
So if you want, say, [red]10 modulo 5[/red], that would be

expr {fmod(10,5)}

_________________
Bob Rashkin
 
sorry guys, i did not give a clear description!!!

I wanted to have the (abs) solution!!!

Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top