mirror of
https://github.com/irmen/prog8.git
synced 2025-04-07 16:41:46 +00:00
removed floats.fabs() and floats.sqrt()/fsqrt()
This commit is contained in:
parent
f37f062cdc
commit
1af38e62bc
@ -39,18 +39,6 @@ sub pow(float value, float power) -> float {
|
||||
}}
|
||||
}
|
||||
|
||||
sub fabs(float value) -> float {
|
||||
%asm {{
|
||||
stx P8ZP_SCRATCH_REG
|
||||
lda #<value
|
||||
ldy #>value
|
||||
jsr MOVFM
|
||||
jsr ABS
|
||||
ldx P8ZP_SCRATCH_REG
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
sub sin(float angle) -> float {
|
||||
%asm {{
|
||||
lda #<angle
|
||||
@ -128,18 +116,6 @@ sub log2(float value) -> float {
|
||||
}}
|
||||
}
|
||||
|
||||
sub sqrtf(float value) -> float {
|
||||
%asm {{
|
||||
lda #<value
|
||||
ldy #>value
|
||||
jsr MOVFM
|
||||
stx P8ZP_SCRATCH_REG
|
||||
jsr SQR
|
||||
ldx P8ZP_SCRATCH_REG
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
sub rad(float angle) -> float {
|
||||
; -- convert degrees to radians (d * pi / 180)
|
||||
%asm {{
|
||||
|
@ -25,14 +25,6 @@ sub pow(float value, float power) -> float {
|
||||
}}
|
||||
}
|
||||
|
||||
sub fabs(float value) -> float {
|
||||
%ir {{
|
||||
loadm.f fr0,floats.fabs.value
|
||||
fabs.f fr0,fr0
|
||||
returnr.f fr0
|
||||
}}
|
||||
}
|
||||
|
||||
sub sin(float angle) -> float {
|
||||
%ir {{
|
||||
loadm.f fr0,floats.sin.angle
|
||||
@ -81,14 +73,6 @@ sub log2(float value) -> float {
|
||||
}}
|
||||
}
|
||||
|
||||
sub sqrtf(float value) -> float {
|
||||
%ir {{
|
||||
loadm.f fr0,floats.sqrtf.value
|
||||
sqrt.f fr0,fr0
|
||||
returnr.f fr0
|
||||
}}
|
||||
}
|
||||
|
||||
sub rad(float angle) -> float {
|
||||
; -- convert degrees to radians (d * pi / 180)
|
||||
return angle * PI / 180.0
|
||||
|
@ -87,7 +87,7 @@ main {
|
||||
|
||||
sub div_float(float a1, float a2, float c) {
|
||||
float r = a1/a2
|
||||
if floats.fabs(r-c)<0.00001
|
||||
if abs(r-c)<0.00001
|
||||
txt.print(" ok ")
|
||||
else
|
||||
txt.print("err! ")
|
||||
|
@ -98,7 +98,7 @@ main {
|
||||
|
||||
sub minus_float(float a1, float a2, float c) {
|
||||
float r = a1-a2
|
||||
if floats.fabs(r-c)<0.00001
|
||||
if abs(r-c)<0.00001
|
||||
txt.print(" ok ")
|
||||
else {
|
||||
txt.print("err! ")
|
||||
|
@ -89,7 +89,7 @@ main {
|
||||
|
||||
sub mul_float(float a1, float a2, float c) {
|
||||
float r = a1*a2
|
||||
if floats.fabs(r-c)<0.00001
|
||||
if abs(r-c)<0.00001
|
||||
txt.print(" ok ")
|
||||
else
|
||||
txt.print("err! ")
|
||||
|
@ -93,7 +93,7 @@ main {
|
||||
|
||||
sub plus_float(float a1, float a2, float c) {
|
||||
float r = a1+a2
|
||||
if floats.fabs(r-c)<0.00001
|
||||
if abs(r-c)<0.00001
|
||||
txt.print(" ok ")
|
||||
else
|
||||
txt.print("err! ")
|
||||
|
@ -246,9 +246,6 @@ point variables. This includes ``print_f``, the routine used to print floating
|
||||
``deg (x)``
|
||||
Radians to degrees.
|
||||
|
||||
``fabs (x)``
|
||||
Returns the absolute value of x. Deprecated; just use the builtin ``abs(x)`` function instead.
|
||||
|
||||
``floor (x)``
|
||||
Rounds the floating point down to an integer towards minus infinity.
|
||||
|
||||
@ -278,10 +275,6 @@ point variables. This includes ``print_f``, the routine used to print floating
|
||||
If you want a fast integer sine, have a look at examples/cx16/sincos.p8
|
||||
that contains various lookup tables generated by the 64tass assembler.
|
||||
|
||||
``sqrtf (x)``
|
||||
Floating point Square root. Deprecated; just use the ``sqrt (x)`` builtin fuction instead.
|
||||
To do the reverse, squaring a floating point number, just write ``x*x``.
|
||||
|
||||
``tan (x)``
|
||||
Tangent.
|
||||
|
||||
|
@ -5,8 +5,8 @@ For 9.0 major changes
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
- DONE: added 'cbm' block in the syslib module that now contains all CBM compatible kernal routines and variables
|
||||
- DONE: added min() max() builtin functions
|
||||
- DONE: rename sqrt16() to just sqrt(), make it accept multiple numeric types. Renamed floats.sqrt() to floats.sqrtf() but you can just use sqrt()
|
||||
- DONE: abs() now supports multiple datatypes including float. No need to use floats.fabs() anymore.
|
||||
- DONE: rename sqrt16() to just sqrt(), make it accept multiple numeric types including float. Removed floats.sqrt().
|
||||
- DONE: abs() now supports multiple datatypes including float. Removed floats.fabs().
|
||||
- DONE: divmod() now supports multiple datatypes. divmodw() has been removed.
|
||||
- DONE: cx16diskio module merged into diskio (which got specialized for commander x16 target). load() and load_raw() with extra ram bank parameter are gone.
|
||||
- DONE: drivenumber parameter removed from all routines in diskio module. The drive to work on is now simply stored as a diskio.drivenumber variable, which defaults to 8.
|
||||
|
@ -44,11 +44,17 @@ For loops now do a check at the start and skip the whole loop if the start value
|
||||
This is the normal behavior of most other programming languages.
|
||||
|
||||
|
||||
For 9.0 major changes
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
- DONE: added min() max() builtin functions
|
||||
- DONE: rename sqrt16() to just sqrt(), make it accept multiple numeric types. Renamed floats.sqrt() to floats.sqrtf() but you can just use sqrt()
|
||||
- DONE: abs() now supports multiple datatypes including float. No need to use floats.fabs() anymore.
|
||||
- DONE: divmod() now supports multiple datatypes. divmodw() has been removed.
|
||||
divmod(), sqrt() and abs() builtin functions accept multiple data types
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- ``divmodw()`` doesn't exist anymore, just use ``divmod()``.
|
||||
- ``sqrt16()`` doesn't exist anymore, just use ``sqrt()``.
|
||||
- ``floats.fabs()`` and ``floats.sqrt()`` don't exist anymore, just use ``abs()`` and ``sqrt()`` they now accept floating point as well.
|
||||
|
||||
|
||||
min() and max() are new builtin functions
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
If you used symbols named ``min`` or ``max`` you have to choose a new name as these are now
|
||||
reserved for the two new builtin functions.
|
||||
Code that uses an if statement and a comparison to determine the greater or lesser of two values,
|
||||
can now be optimized by just using one of these new builtin functions.
|
||||
|
||||
|
@ -1,18 +1,21 @@
|
||||
%import floats
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
word vfrom = $1000
|
||||
word vto = $1000
|
||||
word ww = -1234
|
||||
float fl = 123.34
|
||||
byte bb = -99
|
||||
|
||||
word xx
|
||||
for xx in vfrom to vto step -1 {
|
||||
txt.print_w(xx)
|
||||
txt.spc()
|
||||
}
|
||||
skip:
|
||||
txt.print_w(abs(ww))
|
||||
txt.nl()
|
||||
txt.print_b(abs(bb))
|
||||
txt.nl()
|
||||
floats.print_f(abs(fl))
|
||||
txt.nl()
|
||||
floats.print_f(sqrt(fl))
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user