Skip to content

K_NUMBER doesn't allow negative or decimal numbers

I need to get a number input from the user between two values, such as between -100 and 100. The number could be a decimal number.

K_NUMBER is really more like K_SIGNEDINT. Some optiosn

Allow K_NUMBER to accept - and . characters though this could cause regression issues when it comes to checking values.

K_REALNUMBER that will accept - and . characters so you can enter a negative real number.

A new method such as getrnum that will allow the use of a signed decimal.

You'll probably tell me to use getstr and then check if the variable is a number, but that sort of defeats the purpose of allowing the user to enter only numbers and - . characters.

Or open to other options.

Edited by Nigel Reed