Fix: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Brendon (talk | contribs)
Created page with "FIX(''number'') '''Description''' FIX removes the fractional part from a number, returning the integer closest to 0. The required parameter, ''number'', is any numeric expre..."
 
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
FIX(''number'')
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.''  


'''Description'''
Fix(''number'')


FIX removes the fractional part from a number, returning the integer closest to 0. The required parameter, ''number'', is any numeric expression. When ''number'' is positive, the next smallest integer is returned; when ''number'' is negative, the next largest integer is returned. The required parameter, ''number'', is any valid numeric expression.
== Description ==


'''Example'''
Fix removes the fractional part from a number, returning the integer closest to 0. The required parameter, ''number'', is any numeric expression. When ''number'' is positive, the next smallest integer is returned; when ''number'' is negative, the next largest integer is returned. The required parameter, ''number'', is any valid numeric expression.
 
== Example (Basic) ==


<pre>
<pre>
REM FIX Example
Rem Fix Example
'FIX converts floats to int nearest 0
'Fix converts floats to int nearest 0
DIM Pos, Neg
Dim Pos, Neg
Pos = EXP(1)
Pos = Exp(1)
Neg = -EXP(1)
Neg = -Exp(1)
PRINT "FIX(e) = " & FIX(Pos)
Print "Fix(e) = " & Fix(Pos)
PRINT "FIX(-e) = " & FIX(Neg)
Print "Fix(-e) = " & Fix(Neg)
</pre>
</pre>


'''Output'''
== Output ==


<pre>
<pre>
FIX(e) = 2
Fix(e) = 2
FIX(-e) = -2
Fix(-e) = -2
</pre>
</pre>


'''Related Items'''
== Related Items ==
 
[[int|Int]]
 
[[Category:Language Reference]]


[[int|INT]]
[[Category:Math]]

Latest revision as of 17:59, 24 March 2019

This function is for BASIC compatibility. It is not available in pure JavaScript projects.

Fix(number)

Description

Fix removes the fractional part from a number, returning the integer closest to 0. The required parameter, number, is any numeric expression. When number is positive, the next smallest integer is returned; when number is negative, the next largest integer is returned. The required parameter, number, is any valid numeric expression.

Example (Basic)

Rem Fix Example
'Fix converts floats to int nearest 0
Dim Pos, Neg
Pos = Exp(1)
Neg = -Exp(1)
Print "Fix(e) = " & Fix(Pos)
Print "Fix(-e) = " & Fix(Neg)

Output

Fix(e) = 2
Fix(-e) = -2

Related Items

Int