SHARE
TWEET

Untitled

a guest Oct 17th, 2019 164 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Round:String(value:Float, places:Int)
  2.     places = Max(places,0)  'sanity check - you can't round to a negative number of decimal places
  3.    
  4.     If value<0 Return "-"+Round(-value,places)
  5.    
  6.     Local i:Float = Floor(value)    'get integer part
  7.     value -= i              'take away integer part to be left with fractional part
  8.     value *= Pow(10,places)
  9.     Local f:Float = Floor(value)    'round off unwanted digits
  10.     If value - f >= 0.4 f += 1      'round up if first digit rounded off is 5 or greater
  11.     If f = 0
  12.         Return String(i)
  13.     Else
  14.         'If f > 4 i -= 1
  15.         Return i'+"."+f
  16.     Endif
  17. End Function
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top