INT
i = INT (x)
Rounds x downwards to the nearest integer.
x\1
will convert x
to an integer in less
keystrokes than INT, they both round down for positives and up for
negatives. They both drop the fractional part of the number.
Example 1
print int(3.3) ' Output 3
print int(3.7) ' Output 3
print int(-3.3) ' Output -3
print int(-3.7) ' Output -3
Example 2
'INT or alternate.bas 2016-03-06 SmallBASIC 0.12.2 [B+=MGA]
'I think number\1 is eqivalent to INT(number) in less keystrokes
' both of these convert a number to an integer and both round down to do it.
for i = 1 to 20
'which coin should I use
if rnd<.5 then TF=int(rnd*2) else TF=rnd*2\1
? TF,if TF then ? "It is true now."; else ? "Now it's false.";
spc(3)+"press a key or click for next..."
?next
for i=0 to -10 step -1 'they seem to behave the same for negatives too
rnd
test=i+" test = ";test
? " test\1 = " ;test\1
? "int(test) = ";int(test)
?
?next
Code samples using INT
000 hello.bas
001 3 ways to print hello 5 times.bas
002 numeric variables.bas
003 conditional branching.bas
004 loops.bas
005 challenge.bas
006 arrays+.bas
100lines.bas
2048.bas
2048.bas
3d block lettes.bas
3d rotating cube with message.bas
3d wire cube v1.bas
3d_palmx.bas
3d_torus.bas
3dtictac.bas
3dtorus.bas
3dttt.bas
3dttt.bas
4tune.bas
7gables.bas
agendus.bas
ai.bas
amortig.bas
analog clock.bas
anball 1.0.bas
anomail.bas
Another center finder.bas
another look at trig functions.bas
Math
ABS
ABSMAX
ABSMIN
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
ATN
CEIL
COS
COSH
COT
COTH
CSC
CSCH
DEG
DERIV
DETERM
DIFFEQN
EXP
EXPRSEQ
FIX
FLOOR
FRAC
INT
INTERSECT
INVERSE
LINEQN
LOG
LOG10
M3APPLY
M3IDENT
M3ROTATE
M3SCALE
M3TRANS
MAX
MIN
POLYAREA
POLYCENT
POLYEXT
POW
PTDISTLN
PTDISTSEG
PTSIGN
RAD
RND
ROOT
ROUND
SEC
SECH
SEGCOS
SEGLEN
SEGSIN
SEQ
SGN
SIN
SINH
SQR
STATMEAN
STATMEANDEV
STATMEDIAN
STATSPREADP
STATSPREADS
STATSTD
SUM
SUMSQ
TAN
TANH
TRANSPOSE
If there is insufficient information on this page and you wish learn more about INT,
please send an email to smallbasic@gmail.com. You can help to improve information about
INT by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.