CUE Specification – Numeric Literals


First, I updated CUE because new version was released.

$ go install

$ cue version
cue version v0.5.0

go version go1.18.9
       -compiler gc
          GOARCH arm64
            GOOS linux

I tried it all roughly.

$ cat numeric.cue
dec: 123
dec_long: 123_456_789
m: 1K
mi: 1Ki
bin: 0b10000
bin_long: 0b100000000_00000000
oct: 0o700
oct_long: 0o700_000_000
hex: 0xff
hex_long: 0xdead_beef
f: 0.1
fn: .2
e: 1e-1
e2: 1.2e-1

$ cue eval numeric.cue
dec:      123
dec_long: 123456789
m:        1000
mi:       1024
bin:      16
bin_long: 65536
oct:      448
oct_long: 117440512
hex:      255
hex_long: 3735928559
f:        0.1
fn:       0.2
e:        0.1
e2:       0.12

It seemed floating point before multiplier with ‘i’ such as Mi is not able to be used, the specification seemed possible. It may be a chance to read the source code.

Leave a Reply

Your email address will not be published. Required fields are marked *