Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Cardinals

DEFINITION MODULE Cardinals;

(* Alias types for Unsigned Integer Numbers *) 


IMPORT CARD16, CARD32, CARD64, CARD128;


(* SHORTCARD - Alias for smallest cardinal type *)

IMPORT SHORTCARD+; (* import into client module *)


(* LONGLONGCARD - Alias for largest cardinal type *)

IMPORT LONGLONGCARD+; (* import into client module *)


TYPE

(* CARDINAL16 - Alias type for 16-bit unsigned integers *)

<* IF TSIZE(CARDINAL)*8 = 16 *>
    CARDINAL16 = ALIAS OF CARDINAL;
<* ELSE *>
    CARDINAL16 = ALIAS OF CARD16;
<* ENDIF *>


(* CARDINAL32 - Alias type for 32-bit unsigned integers *)

<* IF TSIZE(CARDINAL)*8 = 32 *>
    CARDINAL32 = ALIAS OF CARDINAL;
<* ELSIF TSIZE(LONGCARD)*8 = 32 *>
    CARDINAL32 = ALIAS OF LONGCARD;
<* ELSE *>
    CARDINAL32 = ALIAS OF CARD32;
<* ENDIF *>


(* CARDINAL64 - Alias type for 64-bit unsigned integers *)

<* IF TSIZE(CARDINAL)*8 = 64 *>
    CARDINAL64 = ALIAS OF CARDINAL;
<* ELSIF TSIZE(LONGCARD)*8 = 64 *>
    CARDINAL64 = ALIAS OF LONGCARD;
<* ELSE *>
    CARDINAL64 = ALIAS OF CARD64;
<* ENDIF *>


(* CARDINAL128 - Alias type for 128-bit unsigned integers *)

<* IF TSIZE(CARDINAL)*8 = 128 *>
    CARDINAL128 = ALIAS OF CARDINAL;
<* ELSIF TSIZE(LONGCARD)*8 = 128 *>
    CARDINAL128 = ALIAS OF LONGCARD;
<* ELSE *>
    CARDINAL128 = ALIAS OF CARD128;
<* ENDIF *>

END Cardinals.