be.. Anyone know a good way to take this number (checking it is valid)
and convert it to decimal..
Thanks
Michael
cr...@it.net.au
Look for "ValRadix" in the numerics chapter of the
TP-links site:
http://www.geocities.com/SiliconValley/2926/tp.html
Franz Glaser
I had a look at it, and since I'm quite new to pascal, it is a bit confusing
to me about how exactly this program works.. Can you make it a bit clearer for
me?
Sorry, I thought that I had written it very clearly...
The procedure is used as a flexible replacement for the
TP - built in VAL(S,R,E) procedure. The flexibility is:
it can be used for any number base between 2 (binary)
and 36 (which is seldom used, for some Radix50 tricks only).
The principle is:
Take all chars of the string sequentially from left to
right and convert them to a number, in this case to a
REAL number. There are some special chars, like the leading
hyphen (the MINUS) and the decimal point. Anything else MUST
be a numeric character. Numeric chars in decimal notation are
'0' .. '9', in octal they are '0'..'7' and in binary they
are '0'..'1'.
If you have a radix above 10, eg. for Hex-number notation,
there are not enough ciphers available, so the "standard"
decided to take the characters 'A'..'F' (for Hex).
In any case the principle is the same.
For integer numbers (no decimal point)
For P := 1 to length(S) do
R := R*radix + NumOrd(S[P]);
where numord simply converts the char '0' to the integer 0
etc.
Assume decimal:
R := R*10 + numord(character);
example:
S = '1234';
on start, R=0;
R := R*10+1 --> R = 1
next char
R := R*10+2 --> R = 12
next char
R := R*10+3 --> R = 123
next char
R := R*10+4 --> R = 1234
If a decimal point is encountered, the following
chars do not increase the exponent any more, so that
the number is appended at the right end. But this
is described in the source example in more detail,
using DpL as the "switched" variable.
Franz Glaser
I appended some comments to the file on the TP-links site,
hope this helps. Press "Reload" on your browser.
Franz Glaser
Joel schrieb:
>
> does anyonre know where
> i can get a copy of pascal from the internet
>
> email me at joe...@which.net
Joel a écrit:
>
> does anyonre know where
> i can get a copy of pascal from the internet
>
> email me at joe...@which.net
--
Frederic GUILLIEN
My Web site
http://wwwperso.hol.fr/~fguillei
http://wwwperso.hol.fr/~fguillei/English
Show your support for the Best Windows Development Tool
Join TDAG (The Delphi Advocacy Group)
http://www.tdag.org/