Skip to content

f32 toString emits extra decimals #2873

Closed
@mattjohnsonpint

Description

@mattjohnsonpint

Bug description

Calling toString on an f64 value works as expected, but doing the same on an f32 string introduces extra noise decimals. I suspect it is because the f32 value is being cast to f64 when passed into the dtoa function:

toString(this: f32, radix: i32 = 0): String {
return dtoa(this);
}

export function dtoa(value: f64): String {

Steps to reproduce

console.log((<f64>1.1).toString());  // "1.1"
console.log((<f32>1.1).toString());  // "1.100000023841858"

AssemblyScript version

v0.27.29

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions