Hey guys
Is there a way of rounding the value of levels to for example 2 decimal places?
Regards,
YR
Rounding the value of levels.
-
- Junior Member
- Posts: 13
- Joined: Mon Mar 29, 2010 4:28 am
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
If your question is about display use %.2f as the format for the table tool or custom tables/reports. If you are asking about computation then something similar to what JJ such as
rounded level = INTEGER(level * 100.0 + 0.5)/100.0
should work, though I can't think of a case where this would be very helpful.
rounded level = INTEGER(level * 100.0 + 0.5)/100.0
should work, though I can't think of a case where this would be very helpful.
If you're using Vensim DSS, it's handy to put JJ's formula in a macro, like
:MACRO: ROUND(x,digits)
ROUND = INTEGER(x*10^digits+0.5)/10^digits
~ x
~ |
:END OF MACRO:
a test:
digits=
1
~ [-2,2,1]
~ |
test x=
ROUND(453.123,digits)
~
~ |
Note that precision is also limited by the floating point format.
:MACRO: ROUND(x,digits)
ROUND = INTEGER(x*10^digits+0.5)/10^digits
~ x
~ |
:END OF MACRO:
a test:
digits=
1
~ [-2,2,1]
~ |
test x=
ROUND(453.123,digits)
~
~ |
Note that precision is also limited by the floating point format.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/