Is it intentional that values in the `Double.Compa...
# announcements
r
Is it intentional that values in the
Double.Companion
are not
const
? I cannot do
const val USE_DEFAULT = Double.NEGATIVE_INFINITY
.
s
it’s been a while since I’ve mucked about with this but there may just be too much uncertainty about how representations of +/- inf and NaN are implemented on various platforms to make it a value that can be safely selected and inlined by the compiler. That said, I truly don’t know much about computers so take this w/ a grain of salt lol
k
That's true for some other languages (C++, Python, ...) but primitives on the JVM and JS are fully specified up to the bit level to be IEEE floating points.
s
I figured as much, but multiplatform/native might complicate things there? Honestly not sure how that shakes out
k
I'm not familiar with Native but the docs say it's IEEE so I think that's guaranteed: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html
👍 2
d
It could be because some "const" numbers are not easily expressed in Kotlin? For instance, Double.MIN_VALUE in Java has the hexadecimal literal
0x0.0000000000001P-1022
with the suffix 'P' being the Binary Exponent indicator, so this is 'just' 2^-1074; the binary exponent indicator does not exist in Kotlin so it would be hard to express this number with a literal, making it impossible / improbable to do it with a const
r
I don't see how that's a factor...
k
The more I think about it the more I think it's just a bug/mistake. I guess it's pretty rare to use
NEGATIVE_INFINITY
in an annotation and you're the first to run into it?
r
Could be. I'll try to remember to file a bug tomorrow and see what shakes out.