8000 Floating point arithmetic support · Issue #4 · rafael2k/lua · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Floating point arithmetic support #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
toncho11 opened this issue Mar 4, 2025 · 9 comments
Open

Floating point arithmetic support #4

toncho11 opened this issue Mar 4, 2025 · 9 comments

Comments

@toncho11
Copy link
Collaborator
toncho11 commented Mar 4, 2025

So there will be support for float numbers in the future (any float arithmetic I mean)?
Will it be possible to use sin() and cos() par example?

Single and double precision are supported in Lua 5.1 which this fork is based on, right?
So it is just a question of ironing out the code to support floating point arithmetic and sun() and cos()?

What is exactly the nature of the problem with the math functions? Problem with Watcom compiler or other?

@toncho11
Copy link
Collaborator Author
toncho11 commented Mar 6, 2025

@rafael2k Can you please elaborate? In order to implement a program that uses sin and cos which version of Lua source is OK? I see the main version here is 5.1, but you also release 5.5 experimental as well. Where is the source for 5.5?

@rafael2k
Copy link
Owner
rafael2k commented Mar 6, 2025

So there will be support for float numbers in the future (any float arithmetic I mean)? Will it be possible to use sin() and cos() par example?

Yes, it already is with the Lua55 binary (from Lua 5.5)

Single and double precision are supported in Lua 5.1 which this fork is based on, right? So it is just a question of ironing out the code to support floating point arithmetic and sun() and cos()?

Lua 5.1 I compiled to be integer-only. sin() and cos() already work in the float Lua version (lua55) and will not work on the integer-only version (simply because they do not make sense in the integer-only Lua).

What is exactly the nature of the problem with the math functions? Problem with Watcom compiler or other?

There is no problem with the math functions, they are working fine.

@rafael2k
Copy link
Owner
rafael2k commented Mar 7, 2025

I just created a lua-5.1 branch with floating point support and your patch added. I see the cubes turning.
: )

@ghaerr
Copy link
ghaerr commented Mar 7, 2025

I see the cubes turning.

Nice! Does this mean that the routines in lmathlib.c didn't work, but the OWC math library routines I recently added do? Or were there other changes made?

@rafael2k
Copy link
Owner
rafael2k commented Mar 7, 2025

I see the cubes turning.

Nice! Does this mean that the routines in lmathlib.c didn't work, but the OWC math library routines I recently added do? Or were there other changes made?

lmathlib is just a wrapper to the libc-provided functions. The integer-only Lua build explicitly exclude most mathlib functions on purpose.

@toncho11
Copy link
Collaborator Author
toncho11 commented Mar 7, 2025

Now it works for 5.5 in https://github.com/rafael2k/lua/pulls !!!!!!!!!!!!!!!!!!!!!
I have not tested the latest changes with 5.1.

@rafael2k
Copy link
Owner
rafael2k commented Mar 7, 2025

Yay! Applied.
We could implement integer-only rotate and project routines for the 5.1i example to see the performance difference. I'll test on bare metal soon.

@toncho11
Copy link
Collaborator Author
toncho11 commented Mar 7, 2025

The Lua 5.5 executable is too times bigger than the 5.1. It runs out of memory fot life.lua. So at this stage both are needed.

Also 5.5 seems to always print an error at the end of its execution. It works, but it complains "attempt to call a nil value" or "attempt to comapre number with nil". It should be something about an exit code in 5.5.

@rafael2k
Copy link
Owner
rafael2k commented Mar 8, 2025

Indeed, Lua 5.4/5.5 is much bigger.

Lua 5.1 is very stable and we can have at least two customization depending on the needs (speed, but integer only), or "full" Lua 5.1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0