GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | INT

Edit History

INT

i = INT (x)

Home > Reference > Math

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
  test=i+rnd
  ? "     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   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   aquarium v2.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  
This page was last edited on Wed, 19 Apr 2023 15:29:20 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.