Skip to content

Slider can be positioned so .0000000000001 appears.  #128

Description

@jamiethain

Writing a controller for the slider it can be positioned where .999999999999 or .0000000001 appears.

Did a work around to call a function that does round.


  void _setValue(val)
  {
    num valNumber =  num.parse(val.toString());
    valNumber = valNumber.round();
    _valController.text = valNumber.toString();  
  }

Screen Shot 2019-09-03 at 2 10 46 PM

One fix should be to add universal round. (not tested)

number universalRound (num number){
  numDecimals = (number - number.toInt()).toString.length().clamp(0,10); 
  divisor = 10 ^ numDecimals; 

  // multiply by number of decimals add .5 then round then divide by the number of decimals and throw away the remainder. 
  number = (((number * divisor) + .5).round()) ~/ divisor) ;
return number; 

Something like that ... 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions