Skip to content
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

uint64 & int64 Typed Arrays #67

Closed
jfcap opened this issue Mar 12, 2019 · 2 comments
Closed

uint64 & int64 Typed Arrays #67

jfcap opened this issue Mar 12, 2019 · 2 comments

Comments

@jfcap
Copy link

jfcap commented Mar 12, 2019

Since 0382dc9 commit, uint64_t & int64_t typed arrays support have been removed.
Why ?
I know we don't have (yet ?) full proper way to manipulate 64bit integers directly in janet (without truncation) but a lot of numerical C libraries use 64bit integers arrays and it's handy (and efficient) to be able to pass directly such binary data as "standard" janet objects to them.

@bakpakin
Copy link
Member

bakpakin commented Mar 12, 2019

I removed them because there is no way to manipulate them, and likely never will be via the standard number type (a C double). If you read the JavaScript standards for typed arrays, they don't include 64 bit integer support at all for this same reason. I was alerted to the problem via warnings in the Microsoft compiler on Appveyor.

Considering how easy it is to add them back, we can add them if we ever support proper 64 bit integers, maybe via some boxed representation (core/bigint?)

@jfcap
Copy link
Author

jfcap commented Mar 13, 2019

Here a bigint implementation proposal.

https://github.com/jfcap/janet.git (branch bigint)

It's not finished.
But at this stage, some feedbacks are welcome.

janet:0:> (def a (bigint/uint64 0xfff))
4095
janet:30:> (def b (bigint/uint64 "0xffffffffffffffff"))
18446744073709551615
janet:75:> (:/ b a a)
1100048695360
janet:86:> (:- b (:* a 2))
18446744073709543425
janet:102:> (type a)
:core/uint64

TODO :
* marshal/unmarshal
* more operators (bitwize operations ...)
* ... ?
* adding typedArray (u)int64 back ;-)

some tests are available in suite6.janet

@jfcap jfcap mentioned this issue Mar 14, 2019
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

2 participants