*Not an official ACM page*

[Problem C
| 1993 Regional problem set
| My ACM problem archive
| my home page]

##
Problem B

Identifying Legal Pascal Real Constants

Pascal requires that real constants have either a decimal point, or
an exponent (starting with the letter e or E, and officially called a
scale factor), or both, in addition to the usual collection of decimal
digits. If a decimal point is included it must have at least one
decimal digit on each side of it. As expected, a sign (+ or -) may
precede the entire number, or the exponent, or both. Exponents
may not include fractional digits. Blanks may precede or follow
the real constant, but they may not be embedded within it. Note
that the Pascal syntax rules for real constants make no assumptions
about the range of real values, and neither does this problem.
Your task in this problem is to identify legal Pascal real constants.
Each line of the input data contains a candidate which you are to
classify. For each line of the input, display your finding as
illustrated in the example shown below. The input terminates with
a line that contains only an asterisk in column one.

Sample solution, Java

Try the Java solution:

Sample Input

1.2
1.
1.0e-55
e-12
6.5E
1e-12
+4.1234567890E-99999
7.6e+12.5
99
*

### Expected Output

1.2 is legal.
1. is illegal.
1.0e-55 is legal.
e-12 is illegal.
6.5E is illegal.
1e-12 is legal.
+4.1234567890E-99999 is legal.
7.6e+12.5 is illegal.
99 is illegal.

### Judge's Input Data

1.0
1e0
1E000000000000000004
1.
.1
1e-5
1.e4
1e-5.1
1.1.1
1+e5
1e5+
1.1e+9999999999999999999999999999
1111111111111111.111111111111111111111111e999999999999999999999999
1.2345678901234567890012345678901234567890
00000000000000012345678901234567890012345678901234567890.0
00000000000000012345678901234567890012345678901234567890
*

### Expected Output from Judged Runs

1.0 is legal.
1e0 is legal.
1E000000000000000004 is legal.
1. is illegal.
.1 is illegal.
1e-5 is legal.
1.e4 is illegal.
1e-5.1 is illegal.
1.1.1 is illegal.
1+e5 is illegal.
1e5+ is illegal.
1.1e+9999999999999999999999999999 is legal.
1111111111111111.111111111111111111111111e999999999999999999999999 is
legal.
1.2345678901234567890012345678901234567890 is legal.
00000000000000012345678901234567890012345678901234567890.0 is legal.
00000000000000012345678901234567890012345678901234567890 is illegal.

This page maintained by
Ed Karrels.

Last updated April 15, 1998