Talk:Float2String

From Second Life Wiki
Revision as of 20:11, 8 October 2008 by Strife Onizuka (talk | contribs)
Jump to navigation Jump to search

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

  1. Code gives syntax error when copying/pasting code. (superfluous "else"?)
  1. Float2String(-123.456,0,FALSE) yields "--123". Should be "-123".
  1. Float2String(-123.456,0,TRUE) yields "-123.00000123". Should be "-123"

--Rhian Svenska 16:11, 8 October 2008 (PDT)

I think I've fixed all but the last. -- Strife (talk|contribs) 20:11, 8 October 2008 (PDT)