Units
Classes, Interfaces, Objects
Types
Variables
Constants
Functions, Procedures
Identifiers

Unit rjBase

Description

Basic utility functions and procedures.

rjBase does not use any additional units.

Classes, interfaces and objects

None.

Functions and procedures

Overview

function BSwap(const Value: Integer): Integer; overload;
function BSwap(const Value: Cardinal): Cardinal; overload;
function CardinalToHex(const Value, Digits: Cardinal): AnsiString;
procedure FreeAndNil(var Obj);
function IntToStr(const i: Integer): AnsiString;
function LeftMostBit(const Value: Cardinal): Integer;
function Max(const a, b: Cardinal): Cardinal; overload;
function Max(const a, b: Integer): Integer; overload;
function Min(const a, b: Cardinal): Cardinal; overload;
function Min(const a, b: Integer): Integer; overload;
function RightMostBit(const Value: Cardinal): Integer;
procedure ZeroMem(var X; const Count: Cardinal);

Description

function BSwap(const Value: Integer): Integer; overload;

Reverses the byte order of a given integer number. For example, 001.002.003.004 returns 004.003.002.001.

function BSwap(const Value: Cardinal): Cardinal; overload;

Reverses the byte order of a given cardinal number. For example, 001.002.003.004 returns 004.003.002.001.

function CardinalToHex(const Value, Digits: Cardinal): AnsiString;

CardinalToHex returns the hex representation of a Cardinal.

The CardinalToHex function converts a number into a string containing the number's hexadecimal (base 16) representation. Value is the number to convert. Digits indicates the minimum number of hexadecimal digits to return.

procedure FreeAndNil(var Obj);

Use FreeAndNil to ensure that a variable is nil after you free the object it references. Pass any variable that represents an object as the Obj parameter.

Warning: Do not pass a value for Obj if it is not an instance of TObject or one of its descendants.

function IntToStr(const i: Integer): AnsiString;

This IntToStr implementation is faster than the original Delphi IntToStr function found in SysUtils.pas.

function LeftMostBit(const Value: Cardinal): Integer;

Returns the index of the leftmost set bit in Value. Bits are indexed from right to left, starting with 0 and ending with 31. If no bit is set in Value, LeftMostBit returns -1.

See also: RightMostBit.

function Max(const a, b: Cardinal): Cardinal; overload;

Max returns the greater of two numeric values.

function Max(const a, b: Integer): Integer; overload;

Max returns the greater of two numeric values.

function Min(const a, b: Cardinal): Cardinal; overload;

Min returns the lesser of two numeric values.

function Min(const a, b: Integer): Integer; overload;

Min returns the lesser of two numeric values.

function RightMostBit(const Value: Cardinal): Integer;

Returns the index of the rightmost set bit in Value. Bits are indexed from right to left, starting with 0 and ending with 31. If no bit is set in Value, RightMostBit returns -1.

See also: LeftMostBit.

procedure ZeroMem(var X; const Count: Cardinal);

Fills Count contiguous bytes with 0 (zero).

Warning: This function does not perform any range checking.

Types

None.

Constants

None.

Variables

None.

Author

Ralf Junker -- delphi@zeitungsjunge.de


rjExContainer Library Version 0.2.
Copyright Ralf Junker 2000-2001.
http://www.zeitungsjunge.de/delphi/.