HowbeitGirl
HowbeitGirl

Reputation: 591

App Inventor Slider : Setting it for whole values?

How do I set the slider to increment by a whole number, not by a decimal value of .N? I can get the value to translate to a label, but I don't want it in decimal value.

This was my original reference: https://www.youtube.com/watch?v=P80FkfGvHWw

Edit: My Code As of Now For My Slider

My value needs to be at 5 maximum... but I do not want to receive the decimal values at all. I eliminated most of the possible fractional values, but there are still some options.

Between 1-5, is there a mathematical way that can automatically round fractions to a whole number?

Thank you! (Please ignore the comment, that was for something else)

Upvotes: 0

Views: 6521

Answers (1)

Taifun
Taifun

Reputation: 6293

see the documentation

round

Returns the given number rounded to the closest integer. If the fractional part is < .5 it will be rounded down. It it is > .5 it will be rounded up. If it is exactly equal to .5, numbers with an even whole part will be rounded down, and numbers with an odd whole part will be rounded up. (This method is called round to even.)

enter image description here

Probably also a good idea is to use Do it, see also the Top 5 Tips how to learn App Inventor. You also can simplify your blocks a bit instead of using 3 times set global wholeInt ...

Upvotes: 2

Related Questions