Squirm
02-05-2003, 03:08 PM
String Math Part II
Attached is a module containing a few string math functions:
StrAdd
takes two strings, adds them, and returns the result in a string
StrSub
takes two strings, subtracts the second from the first and returns the result in a string
StrMult
takes two strings, multiplies them together and returns the result in a string
StrDiv
takes two strings, divides the first by the second and returns the integer portion of the result in a string
StrMod
takes two strings, divides the first by the second and returns the remainder in a string
StrPow
takes two strings, raises the first to the power of the second and returns the result in a string
StrGT
takes two strings, compares them, and returns True if the first is greater than the the second and False otherwise
StrTrim
takes one string, removes the leading zeros from the beginning of it and returns the result in a string
Its also has comments, hopefully they will be of help.
I had a stab at doing some bitwise functions but quickly realised that is a huge undertaking.
The functions provided work only with positive integers, no fractional/decimal numbers or negatives.
Other than that, the only limit to number size is the limit of a string. Or your patience.
:)
Attached is a module containing a few string math functions:
StrAdd
takes two strings, adds them, and returns the result in a string
StrSub
takes two strings, subtracts the second from the first and returns the result in a string
StrMult
takes two strings, multiplies them together and returns the result in a string
StrDiv
takes two strings, divides the first by the second and returns the integer portion of the result in a string
StrMod
takes two strings, divides the first by the second and returns the remainder in a string
StrPow
takes two strings, raises the first to the power of the second and returns the result in a string
StrGT
takes two strings, compares them, and returns True if the first is greater than the the second and False otherwise
StrTrim
takes one string, removes the leading zeros from the beginning of it and returns the result in a string
Its also has comments, hopefully they will be of help.
I had a stab at doing some bitwise functions but quickly realised that is a huge undertaking.
The functions provided work only with positive integers, no fractional/decimal numbers or negatives.
Other than that, the only limit to number size is the limit of a string. Or your patience.
:)