Difference between revisions of "Talk:Float2String"
Jump to navigation
Jump to search
(New page: Please be kind to totally review your text and code; examples are false, code is insufficiently implemented. Examples: string myFormattedFloat = Float2String(-7.1373699,3,"Round"); //roun...) |
(New section: Errors with posted code) |
||
Line 23: | Line 23: | ||
Garmin Kawaguichi | Garmin Kawaguichi | ||
== Errors with posted code == | |||
#Code gives syntax error when copying/pasting code. (superfluous "else"?) | |||
#Float2String(-123.456,0,FALSE) yields "--123". Should be "-123". | |||
#Float2String(-123.456,0,TRUE) yields "-123.00000123". Should be "-123" | |||
--[[User:Rhian Svenska|Rhian Svenska]] 16:11, 8 October 2008 (PDT) |
Revision as of 16:11, 8 October 2008
Please be kind to totally review your text and code; examples are false, code is insufficiently implemented.
Examples: string myFormattedFloat = Float2String(-7.1373699,3,"Round"); //rounded returns -7.14
string myFormattedFloat = Float2String(-7.1373699,3,""); //not rounded returns -7.13
The real result is -7.137 for the both
Code:
if (places == 0) { return neg + (string) ((integer)num ); }
This is true if you want to truncate it, but false if you want to round it.
Other: To round it's written : "should be set to "Rounded" for Yes" in the expanations, //rnd (rounding) should be set to "Rounded" for Yes, "" for not rounded in a Comment Line and Yes in the code. Note that the wiki is first for people who want to study LSL.
Garmin Kawaguichi
Errors with posted code
- Code gives syntax error when copying/pasting code. (superfluous "else"?)
- Float2String(-123.456,0,FALSE) yields "--123". Should be "-123".
- Float2String(-123.456,0,TRUE) yields "-123.00000123". Should be "-123"
--Rhian Svenska 16:11, 8 October 2008 (PDT)