Skip to content

Commit dca8f0a

Browse files
committed
Support uppercase P in hex float literals
1 parent b361259 commit dca8f0a

2 files changed

Lines changed: 49 additions & 49 deletions

File tree

src/julia-parser.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
(if (and (not (eof-object? d))
258258
(or (char-numeric? d) (eqv? d #\+) (eqv? d #\-)))
259259
(begin (set! is-float32-literal (eqv? c #\f))
260-
(set! is-hex-float-literal (eqv? c #\p))
260+
(set! is-hex-float-literal (or (eqv? c #\p) (eqv? c #\P)))
261261
(write-char c str)
262262
(write-char (read-char port) str)
263263
(read-digs #f)

test/numbers.jl

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,54 +1140,54 @@ end
11401140
@test 1f1 == 10.
11411141

11421142
# hexadecimal float literals
1143-
@test isa(0x1p0, Float64)
1144-
@test isa(0x1p1, Float64)
1145-
@test isa(0x.1p0, Float64)
1146-
@test isa(0x.1p1, Float64)
1147-
@test isa(0xfp0, Float64)
1148-
@test isa(0xfp1, Float64)
1149-
@test isa(0x.fp0, Float64)
1150-
@test isa(0x.fp1, Float64)
1151-
@test isa(0x1.p0, Float64)
1152-
@test isa(0x1.p1, Float64)
1153-
@test isa(0xf.p0, Float64)
1154-
@test isa(0xf.p1, Float64)
1155-
@test isa(0x1.0p0, Float64)
1156-
@test isa(0x1.0p1, Float64)
1157-
@test isa(0x1.1p0, Float64)
1158-
@test isa(0x1.1p1, Float64)
1159-
@test isa(0x1.fp0, Float64)
1160-
@test isa(0x1.fp1, Float64)
1161-
@test isa(0xf.0p0, Float64)
1162-
@test isa(0xf.0p1, Float64)
1163-
@test isa(0xf.1p0, Float64)
1164-
@test isa(0xf.1p1, Float64)
1165-
@test isa(0xf.fp0, Float64)
1166-
@test isa(0xf.fp1, Float64)
1167-
@test 0x1p0 == 1
1168-
@test 0x1p1 == 2
1169-
@test 0x.1p0 == 0.0625
1170-
@test 0x.1p1 == 0.125
1171-
@test 0xfp0 == 15
1172-
@test 0xfp1 == 30
1173-
@test 0x.fp0 == 0.9375
1174-
@test 0x.fp1 == 1.875
1175-
@test 0x1.p0 == 1
1176-
@test 0x1.p1 == 2
1177-
@test 0xf.p0 == 15
1178-
@test 0xf.p1 == 30
1179-
@test 0x1.0p0 == 1
1180-
@test 0x1.0p1 == 2
1181-
@test 0x1.1p0 == 1.0625
1182-
@test 0x1.1p1 == 2.125
1183-
@test 0x1.fp0 == 1.9375
1184-
@test 0x1.fp1 == 3.875
1185-
@test 0xf.0p0 == 15
1186-
@test 0xf.0p1 == 30
1187-
@test 0xf.1p0 == 15.0625
1188-
@test 0xf.1p1 == 30.125
1189-
@test 0xf.fp0 == 15.9375
1190-
@test 0xf.fp1 == 31.875
1143+
@test 0x1p0 === 1.
1144+
@test 0x1p1 === 2.
1145+
@test 0x.1p0 === 0.0625
1146+
@test 0x.1p1 === 0.125
1147+
@test 0xfp0 === 15.
1148+
@test 0xfp1 === 30.
1149+
@test 0x.fp0 === 0.9375
1150+
@test 0x.fp1 === 1.875
1151+
@test 0x1.p0 === 1.
1152+
@test 0x1.p1 === 2.
1153+
@test 0xf.p0 === 15.
1154+
@test 0xf.p1 === 30.
1155+
@test 0x1.0p0 === 1.
1156+
@test 0x1.0p1 === 2.
1157+
@test 0x1.1p0 === 1.0625
1158+
@test 0x1.1p1 === 2.125
1159+
@test 0x1.fp0 === 1.9375
1160+
@test 0x1.fp1 === 3.875
1161+
@test 0xf.0p0 === 15.
1162+
@test 0xf.0p1 === 30.
1163+
@test 0xf.1p0 === 15.0625
1164+
@test 0xf.1p1 === 30.125
1165+
@test 0xf.fp0 === 15.9375
1166+
@test 0xf.fp1 === 31.875
1167+
@test 0x1P0 === 1.
1168+
@test 0x1P1 === 2.
1169+
@test 0x.1P0 === 0.0625
1170+
@test 0x.1P1 === 0.125
1171+
@test 0xfP0 === 15.
1172+
@test 0xfP1 === 30.
1173+
@test 0x.fP0 === 0.9375
1174+
@test 0x.fP1 === 1.875
1175+
@test 0x1.P0 === 1.
1176+
@test 0x1.P1 === 2.
1177+
@test 0xf.P0 === 15.
1178+
@test 0xf.P1 === 30.
1179+
@test 0x1.0P0 === 1.
1180+
@test 0x1.0P1 === 2.
1181+
@test 0x1.1P0 === 1.0625
1182+
@test 0x1.1P1 === 2.125
1183+
@test 0x1.fP0 === 1.9375
1184+
@test 0x1.fP1 === 3.875
1185+
@test 0xf.0P0 === 15.
1186+
@test 0xf.0P1 === 30.
1187+
@test 0xf.1P0 === 15.0625
1188+
@test 0xf.1P1 === 30.125
1189+
@test 0xf.fP0 === 15.9375
1190+
@test 0xf.fP1 === 31.875
11911191

11921192
# eps / realmin / realmax
11931193
@test 0x1p-52 == eps()

0 commit comments

Comments
 (0)