Discussion:
OBNC - a few questions
(too old to reply)
d***@gmail.com
2017-11-22 19:44:56 UTC
Permalink
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.

My questions are:
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?

2. General question about Oberon 7:
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
c***@gmail.com
2017-11-22 20:46:09 UTC
Permalink
Post by d***@gmail.com
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
ASSERT(FALSE) is equivalent to HALT.

SYSTEM.SIZE is equivalent to SIZE.

Chris Burrows
CFB Software
http://www.astrobe.com
d***@gmail.com
2017-11-23 00:36:00 UTC
Permalink
Post by c***@gmail.com
Post by d***@gmail.com
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
ASSERT(FALSE) is equivalent to HALT.
SYSTEM.SIZE is equivalent to SIZE.
Chris Burrows
CFB Software
http://www.astrobe.com
d***@gmail.com
2017-11-23 00:37:48 UTC
Permalink
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
In response to the reply:

It appears that on onbc 0.19.1 that you cannot import SYSTEM.
d***@gmail.com
2017-11-23 02:02:14 UTC
Permalink
Post by d***@gmail.com
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
It appears that on onbc 0.19.1 that you cannot import SYSTEM.
make that obnc 0.9.1
d***@gmail.com
2017-11-23 02:04:19 UTC
Permalink
Post by d***@gmail.com
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
It appears that on onbc 0.19.1 that you cannot import SYSTEM.
Make that obnc 0.9.1
d***@gmail.com
2017-11-23 01:58:08 UTC
Permalink
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
d***@gmail.com
2017-11-23 01:58:59 UTC
Permalink
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
Make that obnc 0.9.1
d***@gmail.com
2017-11-23 02:00:44 UTC
Permalink
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
d***@gmail.com
2017-11-23 02:01:29 UTC
Permalink
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
It appears that obnc 0.9.1 does not allow IMPORT SYSTEM
c***@gmail.com
2017-11-23 10:25:31 UTC
Permalink
Post by d***@gmail.com
It appears that obnc 0.9.1 does not allow IMPORT SYSTEM
In that case, check here to see if there are any alternative compilers that meet your requirements:

http://oberon07.com/compilers.xhtml

Regards,
Chris Burrows
CFB Software
http://www.astrobe.com
miasap
2018-03-06 12:48:56 UTC
Permalink
Post by d***@gmail.com
It appears that obnc 0.9.1 does not allow IMPORT SYSTEM
The module SYSTEM is implemented in OBNC 0.12.0.


-- Karl

miasap
2017-11-23 12:06:14 UTC
Permalink
Hi,

Author of OBNC here.
Post by d***@gmail.com
I am using Ubuntu 16.04.2 x86_64. The install went very smoothly.
I'm glad to hear that.
Post by d***@gmail.com
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
INTEGER maps to int and REAL to double. You can see the generated C
files in the hidden .obnc directory. INTEGER, REAL and BYTE are the only
numeric types available in OBNC.
Post by d***@gmail.com
Is there a workaround for the functionality of HALT, EXIT and
SIZE in Oberon 2 ?
As mentioned by Chris, HALT has been eliminated in favor of ASSERT(FALSE).

A LOOP statement (with EXIT) can be rewritten as a WHILE statement with
a loop guard named `done' or similar.

For implementations which support the (optional) module SYSTEM you
typically get the size of a type with SYSTEM.SIZE. OBNC, however, does
not implement a SYSTEM module because all low-level/non-portable code is
supposed to be written in C.

Below is an example of how to get the size of INTEGER and REAL using
OBNC. You can get a template for Limits.c by copying .obnc/Limits.c to
the current directory. See also the section "Interfacing to C" in `man
obnc'.

Limits.obn:

MODULE Limits;

VAR
integerSize*: INTEGER;
realSize*: INTEGER;

END Limits.

Limits.c:

#include <obnc/OBNC.h>
#include ".obnc/Limits.h"

int Limits_integerSize_;

int Limits_realSize_;

void Limits_Init(void)
{
Limits_integerSize_ = sizeof (int);
Limits_realSize_ = sizeof (double);
}

Test.obn:

MODULE test;

IMPORT Limits, Out;

BEGIN
Out.String("size of INTEGER: ");
Out.Int(Limits.integerSize, 0);
Out.Ln;
Out.String("size of REAL: ");
Out.Int(Limits.realSize, 0);
Out.Ln;
END test.


Regards,
Karl
miasap
2017-11-23 12:18:00 UTC
Permalink
If they are not 64 and 80 bits, is there any way to get data of that
size?
Just out of curiosity, what kind of application do you work on which
requires numeric types of these sizes?

Regards,
Karl
d***@gmail.com
2017-11-23 13:34:40 UTC
Permalink
Post by miasap
If they are not 64 and 80 bits, is there any way to get data of that
size?
Just out of curiosity, what kind of application do you work on which
requires numeric types of these sizes?
Regards,
Karl
Thanks for your reply Karl. In computational number theory you want all the integer bits that you can get, and to implement multi precision arithmetic, 64 bit integers make life much easier. If there was a SYSTEM module for x86_64 processors you would need 64 bit integers for addresses.

The case for extended real numbers is not so strong for me. Some algorithms suffer from a large roundoff error, and if you can keep the intermediate results in the 80 bit format, your overall results will improve.
miasap
2017-11-23 15:28:23 UTC
Permalink
Post by d***@gmail.com
Post by miasap
If they are not 64 and 80 bits, is there any way to get data of that
size?
Just out of curiosity, what kind of application do you work on which
requires numeric types of these sizes?
Regards,
Karl
Thanks for your reply Karl. In computational number theory you want all the integer bits that you can get, and to implement multi precision arithmetic, 64 bit integers make life much easier. If there was a SYSTEM module for x86_64 processors you would need 64 bit integers for addresses.
Yes, that's an interesting observation. I wonder how Niklaus Wirth would
solve this if he decided to target a 64-bit system.


-- Karl
c***@gmail.com
2017-11-23 20:49:34 UTC
Permalink
Post by miasap
Post by d***@gmail.com
If there was a SYSTEM module for x86_64 processors you would need 64 bit integers for addresses.
Yes, that's an interesting observation. I wonder how Niklaus Wirth would
solve this if he decided to target a 64-bit system.
The size of INTEGER is intentionally implementation-dependent. It could be implemented as 64-bit if the target platform needed it.
miasap
2017-11-24 09:20:34 UTC
Permalink
Post by c***@gmail.com
The size of INTEGER is intentionally implementation-dependent. It could be implemented as 64-bit if the target platform needed it.
Indeed, but then applications will waste a lot of memory when 64-bit
integers are not needed.


-- Karl
c***@gmail.com
2017-11-24 11:24:59 UTC
Permalink
Post by miasap
Post by c***@gmail.com
The size of INTEGER is intentionally implementation-dependent. It could be implemented as 64-bit if the target platform needed it.
Indeed, but then applications will waste a lot of memory when 64-bit
integers are not needed.
Yes - it will always be a tradeoff. However, the same applies to 32-bit systems. I typically use 32-bit integers to store a zero, one etc. in Oberon programs. I wouldn't bother using BYTE just because they happen to be small values.

If you are working on an architecture that requires 64 bits to address memory then shortage of memory is unlikely to be a problem. Your integers will only take up twice as much memory but you could have more than 65000 times as much memory to work with!

BTW this has already been done. The Patchouli Oberon compiler is a 64-bit compiler. According to the documentation INTEGER is 64-bit:

https://github.com/congdm/Patchouli-Compiler/wiki/Detailed-Documentation

--
Chris Burrows
CFB Software
http://www.astrobe.com/RISC5
c***@gmail.com
2017-11-24 12:20:47 UTC
Permalink
Post by c***@gmail.com
Your integers will only take up twice as much memory but you could have more than 65000 times as much memory to work with!
Correction: Oops! Of course that should be *4 billion times* as much memory (i.e. 16 "Exabytes"). However that is the theoretical maximum. Current Windows systems have a limit of 512 Gigabytes which is 128 times the limit of 32-bit Windows systems.
Nemo
2017-11-24 21:34:25 UTC
Permalink
Post by d***@gmail.com
Thanks for your reply Karl. In computational number theory you want all
the integer bits that you can get, and to implement multi precision
arithmetic, 64 bit integers make life much easier. If there was a
SYSTEM module for x86_64 processors you would need 64 bit integers
for addresses.
In this regard, it would be nicer if CARDINAL were kept as you lose a
bit with signed integers (and have all sorts of house-keeping problems).

N.
miasap
2017-11-30 12:23:45 UTC
Permalink
Post by d***@gmail.com
1. What is the bit size for INTEGER and REAL on my machine? If they are
not 64 and 80 bits, is there any way to get data of that size?
OBNC 0.10.0 now has the build options --use-long-int and --use-long-real
which adds the type specifier `long' for the C types corresponding to
INTEGER, SET and REAL. This should enable 64-bit integers and/or 80-bit
floating point numbers on the system you use. The math module in the
basic library only supports double precision, however, so you have to
provide your own for extended precision calculations.

http://miasap.se/obnc/


Regards,
Karl
miasap
2017-12-08 11:45:15 UTC
Permalink
Post by miasap
The math module in the
basic library only supports double precision, however, so you have to
provide your own for extended precision calculations.
OBNC 0.10.1 now supports extended precision calculations in basic module
Math.

http://miasap.se/obnc/


Regards,
Karl
Loading...