TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Weird precision issue

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
nya



Joined: 25 Jun 2012
Posts: 39

PostPosted: Sat Mar 22, 2014 4:18 am    Post subject: Weird precision issue Reply with quote

Hi!

I recently got a teeny tiny little raspberry pi thingy, and totally compiled tintin++ on it. Everything so far seems great, except for one super weird issue. I haven't been able to track down why it's happening (I compiled it with gcc version 4.6.3 if that helps), but essentially each #math statement uses the precision of a previous #math statement.

For example,
Code:
#math {foo} {1.2}
#math {bar} {1}
#math {foobar} {1.2}


Will result in bar containing 1.0, and foobar containing 1, instead of the expected 1 and 1.2 (respectively). foo will, of course, depend on the #math statement executed before it, but if it's the first one executed since the program stated, it'll contain 1 just as foobar would.

I still dunno why it's happening, but it looks like the line

Code:
node = set_nest_node(ses->list[LIST_VARIABLE], left, "%.*f", precision, get_number(ses, right));


is causing it. get_number() changes precision, but it looks like it's passing in precision before running get_number(). I dunno if that's compliant c behavior or not, but changing lines (there are two, I think) from the above to something like:

Code:
result = get_number(ses, right);
node = set_nest_node(ses->list[LIST_VARIABLE], left, "%.*f", precision, result);


seems to fix the behavior.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Sun Mar 23, 2014 6:22 pm    Post subject: Reply with quote

That's probably the better way to go about it. I'll fix that. Thanks for letting me know. Smile
Back to top
View user's profile Send private message Send e-mail
nya



Joined: 25 Jun 2012
Posts: 39

PostPosted: Sun Mar 23, 2014 10:38 pm    Post subject: Reply with quote

Yeah, it might be even better to have the method return precision in some way (either via some number struct that keeps track of both the value and the underlying precision, or just a reference thing), but that small change seemed to be enough to fix it in this case, so whatever!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group