Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small double values are set to zero in %L translation #1919

Closed
DanielGronau opened this issue Jun 3, 2024 · 0 comments
Closed

Small double values are set to zero in %L translation #1919

DanielGronau opened this issue Jun 3, 2024 · 0 comments

Comments

@DanielGronau
Copy link
Contributor

DanielGronau commented Jun 3, 2024

In KotlinPoet 1.17.0 under Kotlin 2.0.0 the code...

listOf(1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001).forEach{
    val cb = CodeBlock.of("%L", it).toString()
    println("$it -> $cb")
}

... results in the following output:

1.0 -> 1.0
0.1 -> 0.1
0.01 -> 0.01
0.001 -> 0.001
1.0E-4 -> 0.0001
1.0E-5 -> 0.0
1.0E-6 -> 0.0

So for 0.00001 and smaller values, the double value becomes 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants