Ben Edwards
08/17/2022, 5:56 PMval purchasedTickets: Int = 10
val totalTickets: Int = 100
percentagePurchased = (purchasedTickets/ totalTickets) * 100
This is obviously going to truncate the numbers inside the brackets so the answer will be wrong but what is the correct way to handle this?Ciaran Sloan
08/17/2022, 6:13 PMval purchasedTickets: Int = 10
val totalTickets: Int = 100
val percentagePurchased = (purchasedTickets.toFloat()/ totalTickets.toFloat()) * 100F
is this what you're looking for?Ben Edwards
08/17/2022, 6:16 PMpercentagePurchased = (purchasedTickets.toFloat() / totaltickets) * 100
However, still testing.Ciaran Sloan
08/17/2022, 6:20 PMephemient
08/17/2022, 6:26 PMval x = 50000000
x + 1 == x // false, of course
x.toFloat() + 1f == x.toFloat() // true due to running out of precision
Ben Edwards
08/17/2022, 6:33 PMephemient
08/17/2022, 6:40 PMBen Edwards
08/17/2022, 6:47 PMMichael de Kaste
08/18/2022, 9:33 AM