Comments (2)
The GForth implementation implements it like this:
Cell olddiff = n1-nlimit;
n2=n1+n;
if (((olddiff^(olddiff+n)) /* the limit is not crossed */
&(olddiff^n)) /* OR it is a wrap-around effect */
>=0) { /* & is used to avoid having two branches for gforth-native */
{ ... }
I can understand this by separately deoptimising the n>=0
and n<0
cases:
Cell olddiff = n1-nlimit;
n2=n1+n;
Cell newdiff = n2-nlimit;
if ((n >= 0) ? (
olddiff < 0 && newdiff >=0
) : (
olddiff >=0 && newdiff < 0
)) { ... }
In other words, we exit the loop if olddiff
and newdiff
have opposite sign and olddiff
and n
have opposite sign.
from beetle.
Submit a patch to gforth based on the above, which replaces the comment "check this thoroughly", and removes the comment about defunct gforth-native
.
from beetle.
Related Issues (11)
- add explicit license HOT 1
- libbeetle should depend on c-decls.h HOT 3
- Fails to link with mijit-beetle on aarch64
- Use mijit-beetle when available HOT 1
- It is not necessary to execute NEXT when beetle starts up.
- Stacks can grow in either direction
- Add VM "core dumps" HOT 1
- Remove memory manager HOT 1
- Remove `@PACKAGE@` where possible
- Division of -2^31 by -1 HOT 1
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 beetle.