[M3devel] unsigned integers?

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Tue Jun 3 02:25:43 CEST 2008

Dear Jay and developers:
>What is the status and chance of a 32 bit integer with the range
>0..0xFFFFFFFF and of a 64 bit integer type with range 0 ..
I guess you meant like a LONGCARD, I think it was a proposal of native 64 integer language update with recent LONGINT add,  but as I understood it was no accepted (maybe it was not  needed). Did you mean UNSIGNED like a  LONGCARD?
There is a Sweden site about the comparison you want to make of C++ types and Modula-3 built-in types (as I understand you want to figure out), maybe this can give you an idea of others thoughts:

Also you can check this opinion based on comparison with Modula-2 too:
Also the m3devel list from 2006. And all the others about 64 native proposal of Rodney Bates and others:
I would vote to keep simplicity even in the mapping of C types to Modula-3 types, does exist any matrix like the translated web of the url above in the documentation of cm3 to help in the implementations of mapping types?
---2/6/08, Jay <jayk123 at hotmail.com> wrote:
De: Jay <jayk123 at hotmail.com>
Asunto: [M3devel] unsigned integers?
Para: "m3devel at elegosoft.com" <m3devel at elegosoft.com>
Fecha: lunes, 2 junio, 2008 4:07

#yiv1585025748 .hmmessage P
#yiv1585025748  .hmmessage

What is the status and chance of a 32 bit integer with the range 0..0xFFFFFFFF and of a 64 bit integer type with range 0 .. 0xFFFFFFFFFFFFFFFF?



Already available?

Impossible to provide?
Only available in unsafe modules?
Only available with restricted operations in safe modules, and more operations in unsafe modules?



Specifically, I think looping from 0 to N is safe -- no overflow.

Subtracting a CARDINAL from an "UNSIGNED" is safe -- cannot overflow.

Adding "UNSIGNED" to "UNSIGNED" is not safe -- can overflow.

Adding or subtracting an INTEGER to "UNSIGNED" is not safe.

Subtracting "UNSIGNED" from "UNSIGNED" is not safe -- can overflow.
Comparing UNSIGNED to UNSIGNED for any of =, <, >, !=, is safe.

Comparing UNSIGNED to CARDINAL or INTEGER is safe, but must be done carefully.

  Specifically, UNSIGNED > LAST(CARDINAL) is not equal to any CARDINAL or UNSIGNED.
The unsafe operations above could be runtime checked perhaps.

  I guess that's a different larger point/dilemna -- when to allow potentially unsafe operations but with runtime checks vs. the compiler just disallowing them entirely. e.g. adding an integer to an integer is not even safe, but checked maybe at runtime (ok, at least assignment to subrange types is checked). Yes, I know I know, the runtime checks on at least many integer operations is yet lacking.


Is there any, um, value in such a type?

Is it just me blindly trying to cast Modula-3 as C (yes), but there's no actual value (uncertain)?


Btw, I agree there's no point in this type in representing file sizes or offsets. They should be at least 63 bit integers. One bit doesn't buy much for file sizes. It might be something for address spaces though?


It bugs me to define types like uintptr_t = CARDINAL or uintptr_t = INTEGER. It seems quite wrong.

Perhaps the unsigned types larger than 16 bits just should not be defined in Cstdint. ??

But there is already Ctypes.unsigned_int, unsigned_long_long, whose underlying type I think is signed, but which convention says you just don't do signed operations on, but which the compiler doesn't enforce, right?


You know, maybe Word.T should not be INTEGER but this mythological UNSIGNED/UINT??????


 - Jay

Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080603/274a0db5/attachment-0002.html>

More information about the M3devel mailing list