Zoltan Demant07/10/2023, 12:22 PM
Joffrey07/10/2023, 12:26 PM
Zoltan Demant07/10/2023, 12:32 PM
Joffrey07/10/2023, 12:33 PM
Whenever I work with fractions, float values make the most sense to me. 0.1f = 10% etc.I'm sorry I don't get that, why not just
(a double) instead of
(a less precise float)?
Zoltan Demant07/10/2023, 12:36 PM
@Composable fun CircularProgressIndicator( progress: Float, )
Joffrey07/10/2023, 12:44 PM
Its the pattern Ive come to know over too many yearsWhat pattern? You might be missing my point.
is also a IEEE 754 floating-point value, just like
, but it's 64bit instead of 32bit, which is more precise and can represent larger numbers. It's also the default for decimal literals like
(unless you force the less precise 32-bit
type by adding an
). That's why I was asking this question. More info: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
in your composable example, and drop the
suffixes in your literals, and everything would work the same (but with more precision)
Zoltan Demant07/10/2023, 1:02 PM
Joffrey07/10/2023, 1:03 PM
Mervyn McCreight07/10/2023, 1:03 PM
- i think the language should not force you to use doubles. what if i’m fully aware of what a float is and i decide that this is all i need for my use-case?
but it's 64bit instead of 32bit
yschimke07/10/2023, 2:02 PM
Joffrey07/10/2023, 2:02 PM
what if i’m fully aware of what a float is and i decide that this is all i need for my use-case?Then... just use a
the language should not force you to use doublesIt doesn't. You still have the option to use the
type, it's not even deprecated. But the language should definitely make it more convenient to do the right thing, and avoid making the wrong things easy to do. So if the right thing is to use
most of the time (unless you have special requirements) then the current state is a good thing. If you have those special requirements, then you should know how you want to sum up your floats and deal with the imprecision.
Fleshgrinder07/12/2023, 5:47 AM
ought to be a
and that the language is doing it wrong right now... not sure if...
yschimke07/12/2023, 6:08 AM
Fleshgrinder07/12/2023, 6:19 AM
is more precise than double, it does not follow that we should use it everywhere. These are all trade offs. In case of integers we trade space for range and in case of floats we trade space for precision. The right choice depends. Otherwise there wouldn't be types like
, ... That the JVM only knows
doesn't mean that other ranges or precisions are bad, it's a JVM design decision. Summing a bunch of floats might be perfectly fine, might be entirely wrong, it depends...