Skip to main content
added 26 characters in body
Source Link
Youka
  • 2.7k
  • 25
  • 35

You expect a number as input and want to check it fits in unsigned int, then do it so. Convert the string to an universal data type for numbers (signed, floating point, much room -> double) and check if it can be casted without precision lost to your wished type.

You want an integer with no sign, so your number has to be positive and, is in given range. (so far see std::numeric_limits helps you) and has no decimal part.

You expect a number as input and want to check it fits in unsigned int, then do it so. Convert the string to an universal data type for numbers (signed, floating point, much room -> double) and check if it can be casted without precision lost to your wished type.

You want an integer with no sign, so your number has to be positive and in given range. std::numeric_limits helps you.

You expect a number as input and want to check it fits in unsigned int, then do it so. Convert the string to an universal data type for numbers (signed, floating point, much room -> double) and check if it can be casted without precision lost to your wished type.

You want an integer with no sign, so your number has to be positive, is in given range (so far see std::numeric_limits) and has no decimal part.

Source Link
Youka
  • 2.7k
  • 25
  • 35

You expect a number as input and want to check it fits in unsigned int, then do it so. Convert the string to an universal data type for numbers (signed, floating point, much room -> double) and check if it can be casted without precision lost to your wished type.

You want an integer with no sign, so your number has to be positive and in given range. std::numeric_limits helps you.