Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determine a value is INTEGER
#1
Let's save I have a value:

Value! = 10.3

and I want to determine if it's an integer.

IF Value! = INT(Value!) THEN
    ' Value! is an INTEGER
END IF

Is this the best way to determine that a number is an integer?

I ask because while perusing other programming language sites I ran across people taking about how this method should NOT be used because of floating point anomalies. They suggest using things like InstanceOf, a combination of ABS and .Floor, and other methods. I realize these examples are commands used with other languages.

Could any "floating point anomalies" with QB64 affect the method I have shown above?
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Determine a value is INTEGER - by TerryRitchie - 07-25-2024, 07:40 PM
RE: Determine a value is INTEGER - by DSMan195276 - 07-26-2024, 12:17 AM
RE: Determine a value is INTEGER - by Pete - 07-26-2024, 12:23 AM
RE: Determine a value is INTEGER - by DSMan195276 - 07-26-2024, 02:33 AM
RE: Determine a value is INTEGER - by Pete - 07-26-2024, 02:41 AM
RE: Determine a value is INTEGER - by Jack - 07-26-2024, 12:25 PM
RE: Determine a value is INTEGER - by Petr - 07-26-2024, 03:02 PM
RE: Determine a value is INTEGER - by Jack - 07-26-2024, 05:25 PM
RE: Determine a value is INTEGER - by DSMan195276 - 07-26-2024, 07:02 PM
RE: Determine a value is INTEGER - by Jack - 07-26-2024, 08:14 PM
RE: Determine a value is INTEGER - by Kernelpanic - 07-26-2024, 10:57 PM
RE: Determine a value is INTEGER - by DSMan195276 - 07-27-2024, 04:30 AM
RE: Determine a value is INTEGER - by Kernelpanic - 07-27-2024, 05:03 PM
RE: Determine a value is INTEGER - by SMcNeill - 07-27-2024, 01:49 PM
RE: Determine a value is INTEGER - by bplus - 07-27-2024, 02:43 PM



Users browsing this thread: 2 Guest(s)