Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric Function
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00257970
Message ID:
00257992
Views:
14
>Am I missing the boat here.
>
>Is there a way to determine is a numeric value is odd or even? or even whole or fractional?
>
IF MOD(nNumeric,2) = 1
   * Odd
ELSE
   * Even
ENDIF

IF nNumeric == INT(nNumeric)
   *  Integer
ELSE
   * fractional portion exists
ENDIF
Not the later one in particular, since the magnitude of numbers may affect whether a fractional portion of a number is testable (very large numbers may not be able to represent or resolve the number with sufficient accuracy, especailly when floating point numbers get involved. With very large FLOAT types, VFP may not be able to even resolve the units or tens place, for example:

SET DECIMALS TO 18
nNum = 1.234567890123E20
? nNum = nNum + 1 && .t.
? nNum = nNum + 10 && .t.
? nNum = nNum + 100 && .t.
? nNum = nNum + 1000 && .t.
? nNum = nNum + 10000 && .f.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform