Modulo string formatting appears to be broken


#1

Given the following on Zerynth and CPython (2.7) string formatting appears to be broken, tested on an ESP32.

floatnum = 10.0
floatnums = "%2.2f" % floatnum
print("Number = '" + floatnums + "'")

print("Length = " + str(len(floatnums)))

for c in floatnums:
    print(str(ord(c)))

On CPython the following is output:

Number = ‘10.00’
Length = 5
49
48
46
48
48

On Zerynth the following is output:

Number = ‘10.0’
Length = 5
49
48
46
48
1


#2

Hello @IainColledge,

have you updated your ESP32 to a p01 VM? You should create it and virtualize again.
Let me know


#3

Yup, just did so, selecting P01 and recompiled + uploaded again.

[info] Starting Virtualization…
[info] Burning bin
[info] esptool.py v2.0
[info] Connecting…

[info] Chip is ESP32D0WDQ5 (revision (unknown 0xa))
[info] Uploading stub…
[info] Running stub…
[info] Stub running…

[info] Configuring flash size…

[info] Auto-detected Flash size: 4MB

[info] Compressed 19520 bytes to 12797…
[info]

[info] Writing at 0x00001000… (100 %)
[info] Wrote 19520 bytes (12797 compressed) at 0x00001000 in 1.1 seconds (effective 137.4 kbit/s)…
[info] Hash of data verified.
[info] Compressed 800048 bytes to 516923…
[info]
[info] Writing at 0x00010000… (3 %)
[info] Writing at 0x00014000… (6 %)
[info] Writing at 0x00018000… (9 %)
[info] Writing at 0x0001c000… (12 %)
[info] Writing at 0x00020000… (15 %)
[info] Writing at 0x00024000… (18 %)
[info] Writing at 0x00028000… (21 %)
[info] Writing at 0x0002c000… (25 %)
[info] Writing at 0x00030000… (28 %)
[info] Writing at 0x00034000… (31 %)
[info] Writing at 0x00038000… (34 %)
[info] Writing at 0x0003c000… (37 %)
[info] Writing at 0x00040000… (40 %)
[info] Writing at 0x00044000… (43 %)
[info] Writing at 0x00048000… (46 %)
[info] Writing at 0x0004c000… (50 %)
[info] Writing at 0x00050000… (53 %)
[info] Writing at 0x00054000… (56 %)
[info] Writing at 0x00058000… (59 %)
[info] Writing at 0x0005c000… (62 %)
[info] Writing at 0x00060000… (65 %)
[info] Writing at 0x00064000… (68 %)
[info] Writing at 0x00068000… (71 %)
[info] Writing at 0x0006c000… (75 %)
[info] Writing at 0x00070000… (78 %)
[info] Writing at 0x00074000… (81 %)
[info] Writing at 0x00078000… (84 %)
[info] Writing at 0x0007c000… (87 %)
[info] Writing at 0x00080000… (90 %)
[info] Writing at 0x00084000… (93 %)
[info] Writing at 0x00088000… (96 %)
[info] Writing at 0x0008c000… (100 %)
[info] Wrote 800048 bytes (516923 compressed) at 0x00010000 in 45.6 seconds (effective 140.4 kbit/s)…
[info] Hash of data verified.
[info] Compressed 3072 bytes to 156…
[info]

[info] Writing at 0x00008000… (100 %)
[info] Wrote 3072 bytes (156 compressed) at 0x00008000 in 0.0 seconds (effective 1208.5 kbit/s)…
[info] Hash of data verified.

[info] Compressed 1024 bytes to 1035…
[info]
[info] Writing at 0x00390000… (100 %)
[info] Wrote 1024 bytes (1035 compressed) at 0x00390000 in 0.1 seconds (effective 83.8 kbit/s)…

[info] Hash of data verified.
[info]
[info] Leaving…
[info] Hard resetting…
[info] Virtualization Ok

Device Virtualized


#4

Hello @IainColledge,

we’ve been able to replicate it, thank you for reporting.
We will fix it with the next update.


#5

Awesome and thanks for the quick response.

I’m working around by using single precision for output i.e. “%2.1f” % floatnum