Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Round:String(value:Float, places:Int)
- places = Max(places,0) 'sanity check - you can't round to a negative number of decimal places
- If value<0 Return "-"+Round(-value,places)
- Local i:Float = Floor(value) 'get integer part
- value -= i 'take away integer part to be left with fractional part
- value *= Pow(10,places)
- Local f:Float = Floor(value) 'round off unwanted digits
- If value - f >= 0.4 f += 1 'round up if first digit rounded off is 5 or greater
- If f = 0
- Return String(i)
- Else
- 'If f > 4 i -= 1
- Return i'+"."+f
- Endif
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement