Skip to content

create valid float string in scientific notation #26045

Description

@kbkpbot

Describe the bug

In scientific notation of float, it should not omit the 0 between . and e.
e.g.
1.0e+10, but not 1.e+10

Although in C and Go, 1.e+10 is a valid format.

This is related to issue #26043

Reproduction Steps

f.v

module main

fn main() {
        val1 := 1.e+10
        val2 := 1.0e+10

        str1 := '${val1}'
        str2 := '${val2}'

        dump(str1)
        dump(str2)
}
v run f.v

Expected Behavior

$ v run f.v
[f.v:10] str1: 1e+10
[f.v:11] str2: 1e+10

Current Behavior

$ v run f.v
[f.v:10] str1: 1.e+10
[f.v:11] str2: 1.e+10

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.12 1cdb0f5.8b423a4

Environment details (OS name and version, etc.)

V full version V 0.4.12 1cdb0f5.8b423a4
OS linux, Ubuntu 24.04.3 LTS
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory 11.02GB/15.51GB
V executable /media/HD/github/kbkpbot/v/v
V last modified time 2025-12-20 01:26:49
V home dir OK, value: /media/HD/github/kbkpbot/v
VMODULES OK, value: /home/mars/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/mars/v/bug/json
Git version git version 2.43.0
V git status weekly.2025.46-247-g97445433
.git/config present true
cc version cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
gcc version gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
clang version Ubuntu clang version 18.1.3 (1ubuntu1)
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.39-0ubuntu8.6) 2.39

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Modules: builtinBugs and problems, concerning the builtin types in V - array, maps, strings, runes.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions