Comments (11)
LSL is not the same as ASH. ASH was a built-in function in Oberon 90 and Oberon-2. It was replaced in Oberon-07 by LSL and ASR. LSL is a logical left shift and ASR an arithmetic right shift. The system module function ROT of Oberon 90 and Oberon-07 was renamed to ROR for right rotation. Even if the type of n is INTEGER in the Oberon-07 specification, I don't think that negative n make sense (i.e. would contradict the fact that the generic ASH was replaced by explicit left and right shift functions). But that's just an assumption, since the language report is not particularly specific. ROR is currently implemented as a simple unsigned shift operation, not a true rotation.
from oberon.
I am not sure what is correct here.
In mathematics, raise to negative whole number become division and raise to zero is defined as one (which in this case does not make sense)
It seems some Oberon-2 code rely on negative argument : https://github.com/Oleg-N-Cher/OfrontPlus/blob/master/Mod/Lib/MathL.cp
If only positive argument is allowed then the value should probably be clamped to positive to avoid the large negative value in the example.
from oberon.
Don't mix up Oberon-2 and before which only had the ASH feature and also had to accept negative n. Oberon-07 is a different case. By the end of the day we just have to define the features which I will specify and implement in Oberon+. I even consider re-adding ASH for backward compatibility. The Component Pascal platform specific issue report (in contrast to all Oberon language reports) is at least explicit for ROT with "(n > 0: left, n < 0: right)".
from oberon.
Thanks for the clarification. I will wait until this is implemented.
from oberon.
I pushed a commit to Github for IDE 0.9.40 which implements a couple of preliminary specification changes;
for one part all BITxyz operations now accept both INTEGER and LONGINT and the result is LONGINT if one of the operands is LONGINT;
the same applies to the ASR built-in function, but only for positive n; I'm not yet sure what actually happens for negative n, but it obviously works with my Oberon System version and it doesn't work anymore if I just replace >> n by << -n for negative n;
then there are two new BITSHL and BITSHR operations for logical left and right shift for positive n and again INTEGER and LONGINT;
finally I added the optional I and L suffix to integer literals to force either INTEGER (I) or LONGINT (L) type and thus to avoid SHORT() or LONG() operations;
the work in progress version of the spec (not yet commited) is attached:
The_Programming_Language_Oberon+.html.gz
from oberon.
Meanwhile I did a lot of practical experiments with the shift functions and finally could derive the true formula for ASR(x,n),
it is ASR(x,n) = x DIV 2^( n MOD w )^
with w the bit width of x.
As you can see it is different from the formula given in the Oberon spec (x DIV 2^n^), and ASR for negative n is not just a left shift (i.e. not the inverse operation of ASR, i.e. not LSL).
The formula for LSL is most likely LSL(x,n) = x * 2^( n MOD w )^
with w the bit width of x (I will do some experiments to confirm this).
Since the Oberon System (and likely other Wirth applications) depends on this feature I can't change it, otherwise these applications won't work anymore.
from oberon.
I added the BITASR(x,n) built-in function and deprecated ASR, ASH, LSL and ROR; please use the BITx functions and only for n >= 0 and < bitwidth; the functions work with both INTEGER and LONGINT.
I also refactored some other built-ins for LONG compatibility.
the work in progress version of the spec (not yet commited) is attached:
The_Programming_Language_Oberon+.html.gz
from oberon.
Happy new year.
Looks like a good choice with the BITXXX name convention.
Also removal of SHORT() or LONG() makes it much cleaner.
I will test this more when I get time to do so.
from oberon.
Thanks, same to you.
SHORT() and LONG() are still available, but since the literals can be typed it is less necessary to use them.
Meanwhile I added all necessary LONGINT and LONGREAL operations to the Oakwood library; commit will go up soon.
from oberon.
Can we close this?
from oberon.
We can close this.
from oberon.
Related Issues (20)
- Invalid IL code exception HOT 17
- Out.String goes past 0x mark HOT 2
- Wrong assembly for some array of record HOT 2
- UTF-8 compiler switch? HOT 6
- Mono hangs when creating a new thread in an external library module HOT 2
- Building for aarch64 error HOT 4
- Error when compiling any Oberon code on Linux Mint HOT 6
- Further development of Oberon+ HOT 29
- Miss *.SO HOT 19
- Handling strings from external sources HOT 10
- PCALL / RAISE problem HOT 6
- Issues with Sqlite binding code HOT 5
- add to binaries to github releases section HOT 3
- Trying to compile a simple example HOT 4
- "Env" like module - access to shell environment variables? HOT 3
- Read from console HOT 5
- VSCode Integration HOT 4
- Sorry, this was a mistake.
- Congrats for Top 10 in Hacker News! HOT 2
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 oberon.