Converting
functions:
Number systems |
|
F_ROMAN2ARABIC |
function from adhoc
|
Entrypoint
|
roman2arabic |
|
Input |
CSTRING(50) |
number
in roman
system as string (upper oder lower) |
Output |
INTEGER |
integer
in
arabic decimal system |
Classic form
also shorten forms are allowed,
f.e. 1999:
classic MCMXCIX
shorten 1
MXMIX
shorten 2 MIM
Also the original roman form is allowed, f.e. 1984:
original
MDCCCCLXXXIIII
classic MCMLXXXIV
Allowed also in roman nor allowed forms, f.e. 1900:
correct
MCM thousend +
(thousend - one hundred)
normaly wrong
MDCD thousend + five hundred + (five
hundred - one hundred)
If there is a not roman digit, f.e. MCA, returns -1
If you don't respect the rule, that in subtraction form only one
digit
in front is allowed (IX allowed, IIX not allowed), returns bullshit.
Great thousend numbers like 10000 are returned correct if you put
in MMMMMMMMMM. Maximum is 250 thousend.
TestSQL
SELECT 1984 AS ISCORRECT, F_ROMAN2ARABIC('MCMLXXXIV') FROM
RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_ROMAN2ARABIC(NULL) FROM RDB$DATABASE; |
|
F_ARABIC2ROMAN |
function from adhoc |
Entrypoint
|
arabic2roman |
|
Input |
INTEGER |
integer
in
arabic decimal system |
Output |
CSTRING(250) |
number
in roman
system (classic form) |
Max. Zahl ist
200000
TESTSQL
SELECT 'MCMLXXXIV' AS ISCORRECT, F_ARABIC2ROMAN(1984) FROM
RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_ARABIC2ROMAN(NULL) FROM RDB$DATABASE; |
|
F_CONVERTFROM33 |
compatible to
FreeUDFLibC |
Entrypoint
|
convertfrom33 |
|
Input |
CSTRING(254) |
number
in
33-system as string |
Output |
INTEGER |
integer
in
decimal system |
TestSQL
SELECT 1000 AS ISCORRECT, F_CONVERTFROM33('WB') FROM RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_CONVERTFROM33(NULL) FROM RDB$DATABASE; |
|
F_CONVERTTO33 |
compatible to FreeUDFLibC |
Entrypoint
|
convertto33 |
|
Input |
INTEGER |
integer
in
decimal system |
Output |
CSTRING(254) |
number
in
33-system |
TestSQL
SELECT 'WB' AS ISCORRECT, F_CONVERTTO33(1000) FROM RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_CONVERTTO33(NULL) FROM RDB$DATABASE; |
|
F_CONVERTFROMBASE |
compatible to FreeUDFLibC |
Entrypoint
|
convertfrombase |
|
Input |
CSTRING(32) |
number
from
anyone number-system as string |
|
INTEGER |
Basis
of the
number which can be converted (for example 2 for binary-system) |
|
CSTRING(8) |
all
numbers,
which are valid in the number-system as string (e.g. ‘01234567' for
oktal-system). |
Output |
INTEGER |
integer
in
decimal system |
TestSQL
SELECT 3 AS ISCORRECT, F_CONVERTFROMBASE('11', 2, '01') FROM
RDB$DATABASE;
SELECT 9 AS ISCORRECT, F_CONVERTFROMBASE('11', 8, '01234567') FROM
RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_CONVERTFROMBASE(NUll, NULL, NULL) FROM
RDB$DATABASE; |
|
F_CONVERTTOBASE |
compatible to FreeUDFLibC |
Entrypoint
|
converttobase |
|
Input |
INTEGER |
integer
in
decimal system |
|
INTEGER |
Basis
of number
to convert (for example 2 for binary-system) |
|
CSTRING(254) |
all
numbers,
which are valid in the number-system as string (e.g. ‘01234567' for
oktal-system) |
Output |
CSTRING(254) |
number
in number-system
descipted in parameter 2 |
TestSQL
SELECT '11' AS ISCORRECT, F_CONVERTTOBASE(3, 2, '01') FROM
RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_CONVERTTOBASE(NULL, NULL, NULL) FROM
RDB$DATABASE; |
|
F_HEXTOINT |
compatible to GrUDF |
Entrypoint
|
hextoint |
|
Input |
CSTRING(20) |
Hexword |
Output |
INTEGER |
integer
in
decimal system |
TestSQL
SELECT 13 AS ISCORRECT, F_HEXTOINT('000000000d') FROM RDB$DATABASE;
SELECT 13 AS ISCORRECT, F_HEXTOINT('d') FROM RDB$DATABASE;
SELECT 13 AS ISCORRECT, F_HEXTOINT('D') FROM RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_HEXTOINT(NULL) FROM RDB$DATABASE; |
|
F_INTTOHEX |
compatible to GrUDF |
Entrypoint
|
inttohex |
|
Input |
INTEGER |
integer
in
decimal system |
|
INTEGER |
amount
of
digits (left filled of with 0) |
Output |
CSTRING(254) |
Hexword |
TestSQL
SELECT '000000000d' AS ISCORRECT, F_INTTOHEX(13, 10) FROM
RDB$DATABASE;
SELECT NULL AS ISCORRECT, F_INTTOHEX(NULL, NULL) FROM RDB$DATABASE; |
|