Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Sun Jul 22, 2012 3:53 pm   

problem with , or . when local is , for decimal numbers
 
(2+2) -> 4 working
(2.1+2) -> error in floating point value
(2,2+2) -> illegal character in expression: ,

My local is , and i dont want change it.
How can i bypass this problem?

Regards
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Jul 22, 2012 4:12 pm   
 
As far as I know there's no way to change the decimal separator, CMUD uses the American format. Why you're getting that error when you try 2.1, I have no idea. What are you trying to do with that expression (store it in a variable, send it to a command/function, etc.)?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sun Jul 22, 2012 5:17 pm   
 
have your script use %replace to switch format back and forth?
_________________
Discord: Shalimarwildcat
Reply with quote
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Sun Jul 22, 2012 5:49 pm   
 
shalimar wrote:
have your script use %replace to switch format back and forth?


No script.

This is result when i just doing in command line:

#show (2+2)
#show (2.1+2)
#show (2,1+2) etc.
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Sun Jul 22, 2012 11:07 pm   
 
My local decimal separator is , (Poland, win7)
#sh (2+2) -> 4 working
#sh (2.1+2) -> 4.1 working
#sh (2,2+2) -> illegal character in expression: ,
Everything is right. I see no dependency on system settings.
Reply with quote
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Sun Jul 22, 2012 11:48 pm   
 
Hmm, so where i have to look to solve this.

When i changed decimal separator to .
My result as follow:
#show (2+2)-> 4
#show (2.1+2)->4.1
#show (2,1+2)->illegal character in expression: ,

I dont want change local settings.

Why it not works?

Win7x64 EN with polish(programmer) keyboard
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Jul 23, 2012 12:48 am   
 
I suspect the problem is the local Windows settings, but I'm not sure. Cmud does not have any internal method of changing the decimals to use a comma, so it may be an interaction between Windows and Cmud.
Reply with quote
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Mon Jul 23, 2012 7:20 pm   
 
So any ideas why its working this way?

I cant use . in local, because of other programs.
Need to use ,

Where i should look?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Jul 24, 2012 12:18 am   
 
Quote:

Where i should look?


CMud does not offer any sort of control over how parameters in a function call are delimited, so effectively CMud in your case cannot tell if (2,1+2) is a list of 2 parameters being passed to some function or the polish locale equivalent of 2.1+2. I don't think it's a matter of knowing/not knowing that the comma is your decimal separator, so much that in your case the decimal separator is now the same as the parameter delimiter (ie, a conflict of functionality).

Since CMud merely inherits the locale settings and doesn't let you override them (and since Windows doesn't let you customize it for individual applications to deal with stuff like this), you will have to execute your math in a different language with better locale support and then convert the results as desired.
_________________
EDIT: I didn't like my old signature
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jul 24, 2012 1:49 pm   
 
One way of dealing with simple cases like this would be to use division instead of decimals, e.g.:
Code:
#show ((%float(21)/10 + 2)

But that will be a pain for more complicated cases.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net