Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Mirsad Todorovac
Subject: `Val' function problems
Date: 7 Aug 2003, 14:31:54
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
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Frank Heckenbach | `Val' function problems | 12 Aug 2003, 01:51:49 |
Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.
Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.
This page was created by Crystal 0.999 (Linux 2.4.27/i686).