Spirik / GEM

Good Enough Menu for Arduino
GNU Lesser General Public License v3.0
245 stars 36 forks source link

Floating point #65

Closed HajmamadAgha closed 1 year ago

HajmamadAgha commented 1 year ago

In a page in menus I need to set floating point numbers, my main problem can be defined this way: "after setting the number to a N digit number I can't set the number to a N+1 digit number". How can I resolve this?

Spirik commented 1 year ago

Hi!

If I understand correctly, you want to extend number of digits after the decimal sign. You have to do this through GEMItem::setPrecision() method beforehand (e.g. when creating menu item, before entering an edit mode of this variable).

For more details regarding mantissa and setPrecision() method see Floating-point variables section in Readme and Create float menu item in wiki.

HajmamadAgha commented 1 year ago

Thanks, Alexander. I think I misinformed my question. My problem is with the integer part. suppose I set the number to 5.0. After doing that I wouldn't be able to extend that to 50.0 because the factor of ten is removed.

HajmamadAgha commented 1 year ago

Or if i want to say better, I want to keep the zeros when showing and changing the number

Spirik commented 1 year ago

Sorry I wasn't able to answer sooner!

I've recorded an example video showing how you can place decimal point anywhere in the number in edit mode. Basically you're editing a string with limited set of characters, so it is not a problem to change 5.0 -> 50.0 or vice versa, you just may have to edit the whole number to achieve that and that is understandable inconvenience, but is possible.