Comma instead of dot


#1

Hi,
I have a little problem. How can I change the “.” to a “,” because in Germany and Austria we are using a comma instead of a dot.

So and now I have a calculation and if I type in 22,2 for example the result is wrong but if I type in 22.2 the result is right :-/ I am verry confused why the “,” isn’t working :frowning:
Is there any way to enable the comma??

Thanks for your help !!!


#2

you mean that in Germany and Austria you write two and half like 2,5 rather than 2.5? I’ve never heard of that before, surely when coding numbers you must still have to use 2.5 not 2,5? I thought it was universal :?


#3
you mean that in Germany and Austria you write two and half like 2,5 rather than 2.5? I've never heard of that before, surely when coding numbers you must still have to use 2.5 not 2,5? I thought it was universal :?

thanks for the quick reply, I think in many countries 2,5 is used instead of 2.5. Please correct me If I am in the wrong site but I think there is no way to say Flash enable the comma instead of the dot :frowning:

Is there any way to listen if the user types for example 2,5 in a textfield with a notifications which informs the user that he/she has to use the dot instead of the comma?


#4

We too use 2,5 instead of 2.5 here in the Netherlands (we actually say 2 comma 5, not 2 dot 5). But once you get to higher schools, they start to teach you that you should forget about the comma, and use dots instead. So some people learn that, others dont.

Personally, I like the dot over the comma, but thats prob cause Im a coder :stuck_out_tongue:


#5

Let the user write the comma and parse the result of the input text to substitute the comma for a dot (the final string to work with will be newStr):

function replaceCommaPerDot(oldStr) {
	newStr = oldStr;
	char1 = [","];
	char2 = ["."];
	for (i = 0; i < char1.length; i++) {
		newStr = newStr.split(char1[i]).join(char2[i]);
	}
	
	return newStr;
}

replaceCommaPerDot(yourInputText.text);

Hope this helps.

<"}}><


#6
We too use 2,5 instead of 2.5 here in the Netherlands (we actually say 2 comma 5, not 2 dot 5) ...

When we use the dot we say “two point five” - I’ve never heard of anyone saying “two dot five” :slight_smile:
They use (and say) the comma in South Africa too. Confused the heck out of me when I first moved there :slight_smile:

designmonster: If you want to allow number entry with commas for decimals use a text “relpace” function before using entry as a number:

 
var decimal:String = "2,5";	
var comma:RegExp = /,/;  
trace(decimal.replace(comma, "."));  

#7

I had no idea, I thought the dot / point was universal and in a digital coding sense I guess it is?

Learn something new every day :slight_smile:


#8

romania uses comma too lol


#9

Also in Spain in many places (like bank notes) you can find something like this:

1.525,50 €


#10
We too use 2,5 instead of 2.5 here in the Netherlands (we actually say 2 comma 5, not 2 dot 5). But once you get to higher schools, they start to teach you that you should forget about the comma, and use dots instead. So some people learn that, others dont.

Personally, I like the dot over the comma, but thats prob cause Im a coder :stuck_out_tongue:

Massive +1.

This is one of the main reasons why it was so great to be taught maths in English (Bilingual edutation :slight_smile: ) - I’ve been drilled to use the dot rather than the comma, and I’m appaled when I’m forced to use it at economics (which is taught in Dutch). I usually write in a mixture of comma’s and dots, although when coding it’s 100% dots for me and I honestly can’t remember that this felt off at any point :stuck_out_tongue:

Dots rather than comma’s - Heck yeah.


#11
I had no idea, I thought the dot / point was universal and in a digital coding sense I guess it is?

Learn something new every day :slight_smile:

Romania uses Comma as well :wink: There are 4/5 european countries that do so.


#12

In think, basically Comma is not use as a mathematical number, but most of the country use common to mention the money value. So if you receive the money data using text field you must write the code to remove all commas.

Dot is a numeric, we don’t use as a separator in any way


#13

definitely we must use comma in currency…

it cant be 1.500.23, so it is 1,500.23

But i m amazed tat for pure math representation pple uses COMMA!?

like the average score of this guys in the test is 99,57? instead of 99.57?

Interesting…


#14
When we use the dot we say "two point five" - I've never heard of anyone saying "two dot five" :)

I meant to say point, wrote dot :slight_smile:


#15

late but there is my solution for this “problem” and it works 100%

var yourString:String = yourTextfield.text;
while (yourString.search(";") != -1) {
	yourString = yourString.replace(",",".");
}

put this lines in your calculation… thats it!
Never thought that it is so simple.


#16
late but there is my solution for this "problem" and it works 100%
var yourString:String = yourTextfield.text;
while (yourString.search(";") != -1) {
	yourString = yourString.replace(",",".");
}

put this lines in your calculation… thats it!
Never thought that it is so simple.

Should that have been a comma instead of a semi-colon in the ‘while’ termination condition? Otherwise you have an infinite loop (or one that never executes depending on whether yourString contains a semi-colon)

You don’t need to use a loop to replace globally; there is a ‘global’ replace flag (‘g’) you can add to regular expressions:

This will replace all instances of “,” in yourString with “.”

var allCommas:RegExp = /,/g;  
yourString = yourString.replace(allCommas, ".");

or simply:

yourString = yourString.replace(/,/g, ".");

#17

there’s a map also :wink:


#18

Or you can use

yourString = yourString.split(",").join(".");

the split() function turns your string into an array, separated by character you specify. And the join() function turns the new array back to a string, joining the separate values by the character you specify as well.

Which means you can also do something like

var str:String = "hello world";
str = str.split("world").join("WORLD");
trace(str); // Output: 'hello WORLD'

#19
Or you can use ... the split() function ...

Is there any advantage to using something so apparently cumbersome instead of the built-in String.replace() function?


#20
you mean that in Germany and Austria you write two and half like 2,5 rather than 2.5? I've never heard of that before, surely when coding numbers you must still have to use 2.5 not 2,5? I thought it was universal :?

same here in Romania 2,5 instead of 2.5

  • 50