Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
I have a small problem with mod function when using US/Imperial units. For values without units or SI units the mod function works file. But if I specify US/Imperial units the precision causes the mod function to give different results. Any suggestions? Also I would like to add a special character to variable names to signify a temporary variable or a parameter passed to a user defined function. I've tried # but sometimes it says function not defined. Any recommendation of a safe special character? |
Ed |
|
|
|
Rank: Administration Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member Joined: 11/07/2008(UTC) Posts: 1,616 Was thanked: 1978 time(s) in 666 post(s)
|
It is not because of Units. Problem is that you uses sharp symbol (#) in the expression. Sharp is a special symbol of the program - it means empty placeholder. You can also check it just by hovering of the last amod(..) definition, you'll see an error. Will fix it.
Best regards, Andrey Ivashov.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
Andrey,
There are two screen shots on this page. The first without the "#" shows that mod(5ft,20ft/20) does not produce a whole number. There is approximately 1ft or 0.3048m left over fractionally. Curiously my amod function did produce a whole number.
The second screen shot with the "#" is to show that some characters are not accepted in variable names. Also I discovered some characters on the key board are short cut key strokes. For example "!" is factorial. I tried evey keystroke that I could think of. Most were either short cuts or not recognized.
|
Ed |
|
|
|
Rank: Administration Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member Joined: 11/07/2008(UTC) Posts: 1,616 Was thanked: 1978 time(s) in 666 post(s)
|
Ahh, ok. Actually I don't see an error here, but it seems that option to choose specific Unit system will fix this stuff. Regards.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
Andrey,
The example you've shown will always give a fractional part.
mod(5,20) is equivalent to the integer of 5/20 = 0 and the remainder is 5 regardless of units.
For mod to work the first argument has to be larger than the second argument. Otherwise it will always return the first argument.
In my example its:
mod(5,20/20) or mod(5,1) which should give 0 but due to precision of units its nearly 1.
For the sake of discussion lets say it's mod(5,2) then the result would be 1. If it were mod(2,5) it would be 2. |
Ed |
|
|
|
Rank: Administration Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member Joined: 11/07/2008(UTC) Posts: 1,616 Was thanked: 1978 time(s) in 666 post(s)
|
Sorry if I didn't understand your point.
It doesn't matter what values you will choose to use as arguments, result will be always the same - Units (if we are talk about not base Units) will always change the result like it shown on the screenshot. Ability to change base Units System will correct the behavior of SMath Studio in that case. If you will enter mod(5*ft,2*ft) (i.e. mod(1.524*m,0.6096*m)) result will be 0.3048 and there is no error here.
Regards.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.