Why does Vensim change numbers without telling me so?

Use this forum to post Vensim related questions.
Post Reply
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Why does Vensim change numbers without telling me so?

Post by gwr »

I had just written an addendum to a former post suggesting entering a number very close but not equal to one as a potential workaround for a problem related to conveyors (cf. http://www.ventanasystems.co.uk/forum/v ... 079#p18401).

But doing so reveals some bad style in software-user-interaction at least in my opinion. Entering a value of '0.999999' will always show as '0.999999' but entering '0.9999999' will end up as 1 the next time you look upon it. That may seem like a trivial issue but as can be seen in the conveyor model above it can sometimes make a rather significant difference. Why does Vensim do so? After all as a user I might know better why I wanted to enter a number close to but unequal to one...

Vensim will not change the value while I enter or or even while I might click 'check syntax' in the equation editior. It does so consealed from my eyes after I have clicked 'ok' and it will not tell me about it.

Are we not working with an interpreted modeling-language? I had believed that I enter text which is then interpreted to run as a model. Obviously this is not the case and my original value is lost.

I do find this bad style and hope it can eventually be changed - I seem to not be alone with this verdict as the problem also arises with external data being read in: http://www.ventanasystems.co.uk/forum/v ... f=2&t=5278

Kind regards,

Guido
Administrator
Super Administrator
Posts: 4621
Joined: Wed Mar 05, 2003 3:10 am

Re: Why does Vensim change numbers without telling me so?

Post by Administrator »

Numbers when entered as constants in Vensim are stored as single precision floating point values. The extra 9 at the end of 0.9999999 brings the number beyond the precision available for single FP numbers, and so it gets rounded to 1.

It might be better to store the numbers in a CIN file if you want to store it as 0.9999999.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply