unsigned_integers(n) 1.0 "flibs"
unsigned_integers - Implement operations with unsigned integers
TABLE OF CONTENTS
The unsigned_integers module provides a number of operations that emulate
unsigned integers in Fortran. For some applications unsigned integers are very useful.
The module uses ordinary integers as the basic data type and adds only those
operations that differ between signed and unsigned integers:
All other operations, including left and right bit shifts (in Fortran), give the same results
for unsigned integers as for signed integers, so that you can safely use the standard operations.
The only caveat is that this presumes two's-complement integers, but those are ubiquitous.
- use unsigned_integers
The name of the module. The module does not use any others.
- c = a .udiv. b
Division with a and b interpreted as unsigned integers.
(Both should be declared as ordinary integers!)
- compare = a .ult. b
- compare = a .ule. b
- compare = a .ugt. b
- compare = a .uge. b
Compare two "unsigned" integers and return the result as a logical.
The result is true if a is smaller than b.
Similarly: .ule., .ugt. and .uge. are the unsigned equivalents of
.le., .gt. and .ge..
- string = to_string( a )
Return a string representing the "unsigned" integer a.
- a = to_unsigned( string )
Return an "unsigned" integer from a string. (Accepts "-1" and "2147483648" - both
represent the unsigned value 2147483648.)
Copyright © 2010 Arjen Markus <firstname.lastname@example.org>