Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slider can be positioned so .0000000000001 appears. #128

Closed
jamiethain opened this issue Sep 3, 2019 · 2 comments
Closed

Slider can be positioned so .0000000000001 appears. #128

jamiethain opened this issue Sep 3, 2019 · 2 comments

Comments

@jamiethain
Copy link

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 ... 
@danvick
Copy link
Collaborator

danvick commented Sep 11, 2019

Hello @jamiethain,
KIndly use divisions attribute to set the number of divisions on the slider to avoid decimals if you don't need them.

@danvick danvick closed this as completed Sep 11, 2019
@jamiethain
Copy link
Author

jamiethain commented Sep 11, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants