mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-12-23 10:29:46 +00:00
9bbac556d3
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@202 4df02467-bbd4-4a76-a152-e7ce94205b78
65 lines
2.6 KiB
Plaintext
65 lines
2.6 KiB
Plaintext
|
|
|
|
ACME
|
|
|
|
...the ACME Crossassembler for Multiple Environments
|
|
|
|
--- floating-point support ---
|
|
|
|
|
|
In release 0.92, ACME gained some experimental support for floating-
|
|
point maths, so you can finally build sin/cos tables directly in ACME.
|
|
But the expression parser still uses integer calculations per default.
|
|
Here are the rules:
|
|
|
|
a) if a maths operation is useless when done with integers, it is done
|
|
with floats and returns a float. Applies to sin(), cos(), tan(),
|
|
arcsin(), arccos(), arctan() and float(): These are always computed in
|
|
float mode and always return floats.
|
|
|
|
b) if a maths operation is useless when done with floats, it is done
|
|
with integers and returns an integer. Applies to NOT, AND, OR, XOR,
|
|
MOD, DIV, LSR, lowbyteof, highbyteof, bankbyteof and int(). These are
|
|
always computed in integer mode and always return integers.
|
|
|
|
c) All other mathematical operations are done in float mode if and
|
|
only if at least one of the operands is a float. So "1/2*2" will give
|
|
zero because it is done in integer mode, but "1.0/2*2" will give 1
|
|
because it is done in float mode.
|
|
|
|
To force a numerical value to be flagged as being a float, just add
|
|
a decimal point and a zero. If a decimal value ends with a
|
|
dot character, ACME switches to using the C type "double" and keeps
|
|
reading digits. The value is then flagged internally as being float.
|
|
CAUTION: Float usage is only activated when a decimal point has been
|
|
found, so don't expect "100000000000000000000" to work.
|
|
"100000000000000000000.0" won't work either, because when the decimal
|
|
point gets parsed, the integer value will have overflown already. As
|
|
there is no support yet for the "e" format (1e20 for 1*10^20) either,
|
|
the only way to enter this value is by writing "1.0 * 10.0 ^ 20.0".
|
|
|
|
Examples:
|
|
|
|
!byte 1 / 2 * 2 ; gives 0 (integer maths)
|
|
!byte 1 / 2 * 2.0 ; gives 0 (1/2 => 0 in integer maths,
|
|
; float usage comes too late)
|
|
!byte 1 / 2.0 * 2 ; gives 1 (FP in effect)
|
|
!byte 1 / 2.0 * 2.0 ; gives 1 (FP in effect)
|
|
!byte 1.0 / 2 * 2 ; gives 1 (FP in effect)
|
|
!byte 1.0 / 2 * 2.0 ; gives 1 (FP in effect)
|
|
!byte 1.0 / 2.0 * 2 ; gives 1 (FP in effect)
|
|
!byte 1.0 / 2.0 * 2.0 ; gives 1 (FP in effect)
|
|
|
|
You can use the new float() and int() functions to ensure the type of
|
|
maths:
|
|
|
|
!byte a / b * c ; depends on a/b/c's internal flags
|
|
!byte float(a) / b * c ; calculation is done as float
|
|
!byte int(a) / int(b) * int(c) ; calculation is done as int
|
|
|
|
As you will have guessed, the trigonometric functions assume radians
|
|
for measuring angles (90 degrees equals PI/2).
|
|
|
|
Have a look at the example source code "trigono.a", it builds some
|
|
sin/cos tables.
|