|
Post by strigoides on Jul 22, 2009 1:05:29 GMT -5
Is there any way for Basic4GL to tell whether a number is a whole number or not/a constant that acts as every whole number?
|
|
OW
Posts a bit
Posts: 100
|
Post by OW on Jul 22, 2009 1:42:36 GMT -5
Maybe something like this:
x=1
y = x + .5
Of course, if there was a "plus or minus" sign, I would use that instead.
|
|
|
Post by Pizzasgood on Aug 2, 2009 9:22:38 GMT -5
B4GL has two types of numbers: integers and reals. An integer is a whole number by definition. Real numbers can have a decimal component. So all you have to do is use the int() function on a variable to see what it would look like as an integer, and if it comes out as a different number than the original, that means the original had a decimal component.
' Returns 1 if num# is whole, 0 otherwise function iswhole(num#) if (num# = int(num#)) then return 1 else return 0 endif endfunction
|
|
|
Post by shadow008 on Aug 4, 2009 19:22:18 GMT -5
i thought it was in how the variable was dimmed
dim x 'int dim x#'real
do cls printr "x ";x printr "x# ";x# x = x + .1 x# = x# + .1 loop
it doesnt show x holding a decimal, only x#, didnt really think of it the way pizzasgood did...
|
|