mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Tweaked rounding of numeric values in watchers
This commit is contained in:
parent
ebcd6fe904
commit
bf9f382bc0
1 changed files with 3 additions and 3 deletions
|
@ -40,11 +40,11 @@ import flash.display.*;
|
|||
|
||||
public class Watcher extends Sprite implements DragClient {
|
||||
|
||||
private static const precision:Number = 1000;
|
||||
private static const decimalPlaces:uint = 6;
|
||||
public static function formatValue(value:*):String {
|
||||
if (value is Number && Math.abs(value) > 0.001) {
|
||||
if (value is Number || (value is String && String(parseFloat(value)) === value)) {
|
||||
// show at most N digits after the decimal point
|
||||
value = Math.round(value * precision) / precision;
|
||||
value = Number(Number(value).toFixed(decimalPlaces));
|
||||
}
|
||||
return '' + value;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue