FLUID-6125: string - number transformations should allow for specifying decimal precision

Metadata

Source
FLUID-6125
Type
Improvement
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Justin Obara
Reporter
Justin Obara
Created
2017-02-07T15:19:32.600-0500
Updated
2017-03-06T09:41:53.672-0500
Versions
  1. 2.0
Fixed Versions
  1. 3.0
Component
  1. Model Transformation System

Description

Due to floating point precision, if a number includes a decimal point, the rendered output is not always what you'd expect. While implementing the textfield steppers in the prefs framework, 1.2 was being displayed as 1.2000000000000002 instead.

See channel conversation: https://botbot.me/freenode/fluid-design/2017-02-07/?msg=80593842&page=1

To work around this, the numberToString transformation should take in options to specify how many decimal places to display.

A potential implementation can be seen on stack overflow ( http://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places/12830454#12830454 )

Comments