Comments (7)
This should now be fixed in v0.14.2 on opam (and FWIW the bleeding edge repos already had this fix - I do recommend them).
I made sure 3*5 = 15, not 21. Sanity preserved.
Thanks to @cwong-ocaml for pushing out the release ahead of our usual schedule.
from hardcaml.
The examples are really written for the bleeding edge version of ocaml, which is not yet released and requires some opam hackery.
However, I tried this specific example out on an Ocaml-4.11.1 compiler with Hardcaml v0.14.1 and it seemed to work fine.
What error are you seeing? Is there anything unusual about the platform you are running on?
from hardcaml.
The error is that 5 * 3 should be equal to 15 (as shown on the example page) but the multiplier is returning 21 :(
(I tested it out on another machine and it also returns 21. Both machines are running ocaml 4.12.0)
from hardcaml.
Gotcha, and I can repeat the error.
This seems like a bug in Bits.select
.
select (of_string "10") 0 0
- : t = 0
which is fine, but:
to_int (select (of_string "10") 0 0)
- : int = 2
The select operation is supposed to mask the result to the required length, but in this case is copying the extraneous bits. Here's a hack which should fix things for you. But realistically, you will need to update to the latest version to really work round this.
let select s h l = (select s h l) &: (ones (h-l+1));;
let (.:[]) s (h,l) = select s h l
from hardcaml.
I am going ask around here how hard to would be to release a 0.14.2 hotfix for this branch.
from hardcaml.
Phew, was starting to doubt that 3 * 5 really did equal 15! Thanks for the workaround, it should be enough for me while I'm just exploring the library.
from hardcaml.
I know what the bug is now - there is a mistake in the C-stubs bindings for bytecode operation. This would work properly if you compiled into native code. We only actually caught this problem when we wrote the documentation as this is roughly the only things we compile as bytecode.
I am keen to get the issue patched if possible.
from hardcaml.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hardcaml.