Unit BaseConv

Copyright (c) 1996 Bill Menees If you like it, e-mail me at bmenees@usit.net

Classes

Functions

Base10ToBaseA - Hexadecimal to Octal

Note: If you pass a negtive and/or floating point value to this function, it will be absolute valued and truncated.
BaseAToBase10 - These support base 2 to 36

Note: This will raise an exception if a negative value or a value with a decimal point is passed to it.
BinAnd - where 10-35 are A-Z
BinNot -
BinOr -
BinShiftLeft -
BinShiftRight -
BinToDec - Decimal to Binary
BinToHex - Octal to Binary
BinToOct - Hexadecimal to Decimal
BinXor -
DecToBin - This is good for values from -2^63+1 to 2^63-1.
DecToHex - Octal to Decimal
DecToOct - Binary to Decimal
HexToBin - Binary to Hexadecimal
HexToDec - Decimal to Hexadecimal
HexToOct - Octal to Hexadecimal
IntPower - Make sure we have a digit in the range 0 - Z (35); If not, then we raise a conversion exception.
OctToBin - Binary to Octal
OctToDec - Decimal to Octal
OctToHex - Hexadecimal to Binary

Types

TBaseName
TBinaryValue

Constants

Variables


Functions


function Base10ToBaseA(Value: TBinaryValue; BaseA: Integer): String;

Hexadecimal to Octal

Note: If you pass a negtive and/or floating point value to this function, it will be absolute valued and truncated.


function BaseAToBase10(BaseA: Integer; Value: String): TBinaryValue;

These support base 2 to 36

Note: This will raise an exception if a negative value or a value with a decimal point is passed to it.


function BinAnd(x, y: TBinaryValue): TBinaryValue;

where 10-35 are A-Z

function BinNot(x: TBinaryValue; WordSize: Integer): TBinaryValue;


function BinOr(x, y: TBinaryValue): TBinaryValue;


function BinShiftLeft(x: TBinaryValue; WordSize: Integer; Rotate: Boolean): TBinaryValue;


function BinShiftRight(x: TBinaryValue; WordSize: Integer; Rotate: Boolean): TBinaryValue;


function BinToDec(Value: string): TBinaryValue;

Decimal to Binary

function BinToHex(Value: string): string;

Octal to Binary

function BinToOct(Value: string): string;

Hexadecimal to Decimal

function BinXor(x, y: TBinaryValue): TBinaryValue;


function DecToBin(Value: TBinaryValue): string;

This is good for values from -2^63+1 to 2^63-1. However, there may be some round off errors here as you get near the limits of the Comp type. E.g. Most values above #FFFFFFFFFFFFFFh get a little bit of error.

function DecToHex(Value: TBinaryValue): string;

Octal to Decimal

function DecToOct(Value: TBinaryValue): string;

Binary to Decimal

function HexToBin(Value: string): string;

Binary to Hexadecimal

function HexToDec(Value: string): TBinaryValue;

Decimal to Hexadecimal

function HexToOct(Value: string): string;

Octal to Hexadecimal

function IntPower(Base, Exponent: Integer): Extended;

Make sure we have a digit in the range 0 - Z (35); If not, then we raise a conversion exception.

function OctToBin(Value: string): string;

Binary to Octal

function OctToDec(Value: string): TBinaryValue;

Decimal to Octal

function OctToHex(Value: string): string;

Hexadecimal to Binary

Types


TBaseName = (Bin, Oct, Dec, Hex);

TBinaryValue = Comp

Constants


Variables