1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-20 22:05:15 +00:00
qb64/internal/help/FIX.txt
Luke Ceddia b586eafd3b Integrated _BLINEINPUT into regular LINE INPUT for BINARY files
LINE INPUT will now use the faster method if passed a file handle
that has been opened FOR BINARY. As such, the _BLINEINPUT command
has been removed.

qb64.bas now takes advantage of this for reading from '$include files,
at least in Include Manager 1. Some tweaking of internal/source/main.txt
was required to get things into a sane state, so I'm holing off changing
the compiler any further so the auto-builder can make sure everything's
smoothed over.

Note: Everything should still compile as normal; I'm just being overcautious.
2014-07-27 00:06:17 +10:00

51 lines
1.1 KiB
Plaintext

The '''FIX''' function rounds a numerical value to the next whole number closest to zero.
{{PageSyntax}}
:: result = [[FIX]](''expression'')
* [[FIX]] effectively truncates (removes) the fractional part of ''expression'', returning the integer part.
* This means that [[FIX]] rounds down for positive values and up for negative values.
''Example 1:'' Showing the behavior of [[FIX]] with positive and negative decimal point values.
{{CodeStart}} '' ''
PRINT FIX(2.5)
PRINT FIX(-2.5) '' ''
{{CodeEnd}}
{{OutputStart}}2
-2
{{OutputEnd}}
''Example 2:'' The NORMAL arithmetic method (round half up) can be achieved using the function in the example code below:
{{CodeStart}} '' ''
{{Cl|PRINT}} MATHROUND(0.5)
{{Cl|PRINT}} MATHROUND(1.5)
{{Cl|PRINT}} MATHROUND(2.5)
{{Cl|PRINT}} MATHROUND(3.5)
{{Cl|PRINT}} MATHROUND(4.5)
{{Cl|PRINT}} MATHROUND(5.5)
{{Cl|FUNCTION}} MATHROUND(n)
MATHROUND = {{Cl|FIX}}(n + 0.5 * {{Cl|SGN}}(n))
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{OutputStart}}1
2
3
4
5
6
{{OutputEnd}}
''See also:''
* [[CINT]], [[CLNG]], [[_ROUND]]
* [[MOD]], [[\|Integer Division]]
* [[/|Normal division]]
{{PageNavigation}}