[Lazarus] floating point mask

David Emerson dle3ab at angelbase.com
Wed Dec 9 19:14:13 CET 2009


> David Emerson wrote:
> > at first I overlooked "e+" which is valid for val (string, real)

Alexander Klenin wrote:
> No, it is not:
>   Val('e+', x, d);

What I meant is that I first overlooked 'e' and '+' as valid characters 
that can appear together within a string to be converted to a float. 
The following compiles and works as expected:

var x : real;
begin
  val ('4.1e+5', x);  // "e+" is valid for val (within context)
  writeln (x);
end.

The point I was making was that if someone is going to make a floating 
point mask (note the subject...) that one should be careful not to 
exclude any valid characters if restricting input by character. I'm not 
sure if the set I suggested ['-', '.', '0'..'9', 'e', 'E', '+'] is 
complete.

Cheers,
~David.





More information about the Lazarus mailing list