Hi!
We spoke earlier about the problem with ec in
Val (source, x, ec)
function, and Frank said it will be fixed in next release (it's exhibited
again in '12#11invalid').
Consider the following second problem that `Val' returns '0' if he finds
more than one non-digit character in `source' string. If there's only one
or zero erroneous digits at the end of number, `Val' converts the number
to `x'.
1. Does Borland Pascal do teh same, or is it a GPC bug?
2. Is the base prefix a GNU Pascal extension, or is it present in
BP too (relevant for docs page)?
3. Val ('$100000000, x, ec) gives
x := 0; ec := 0;
There seem to be no indication of overflow error in this case.
Thanks,
Mirsad
program val;
uses GPC;
var i, ec: Integer;
s : String;
begin
repeat
ReadLn (s);
Val (s, i, ec);
WriteLn (i, ' ', ec);
until i = 1000
end.
bash-2.05b$ gpc --automake val.pas
val.pas:4: warning: missing string capacity -- assuming 255
bash-2.05b$ a.out
12#11
13 0
12#11invalid
0 7
16#ffffg
65535 8
12#11c
13 6
12#11i
13 6
12#11in
0 7
12#11cc
0 7
$ffff
65535 0
$ffffg
65535 6
$ffffgg
0 7
$ffffffff
-1 0
16#ffffffff
-1 0
$100000000
0 0
--
"I have a dream!" -- Martin Luther King Jr.