I have a float or double variable. I want the digits te appear in a label. But I want 2 digits behind the comma. If I just use the toString() method It will not give any digits behind the comma. Just 1 or 2 and not 1,35 or 2,69 What do i need to do?
@buntineApr 29.2005 — #I am assuming you are working with Java. In which case, you need to ask in the Java forum from now on. In a float or a double, there should be a dot, rather than a comma. e.g. 2.69. Also, double and float are primitive types in Java, so they do now have a toString() method.
In any case, which language are you actually using?
In every programming language that I know of that supports floats and doubles, you need to use a decimal point.
Here is an example from Java. I haven't used Java in years, so this might be wrong. <i> </i>double a=0.75; double b=3.5; double c=a+b; // at this point, c will equal 4.25
Please post your code.
Please be aware that arithmetic with doubles can contain small errors.
Try this: <i> </i>int count=0; double total=0; for (count=1; count<=8; count++) total+=0.1; // total will equal 0.8000000000000001
@JuuitchanApr 30.2005 — #If you want to see numbers with commas, I suggest you first convert the numbers to strings, then replace all decimal points with commas.
@ray326Apr 30.2005 — #If you want to see numbers with commas, I suggest you first convert the numbers to strings, then replace all decimal points with commas.[/QUOTE] Are you saying there is no concept of a locale in C#?
@ray326Apr 30.2005 — #AFAIK commas are always used as list item separators. I've also never seen a programming language implementation that used commas for decimal points in its source but I've got a very narrow world view on that.