Float vs Double type for Price value

Hello everyone.

What is the best type to use for price value? Is it Double or Float? I am using Realm objects.
The price should contain only 2 decimals. (10.55$)

Have a nice day!

1 Like

Hi @Ciprian_Gabor,

For prices you want to use the Decimal128 type so all the calculations are absolutely exact (and not rounded to the next float or double) because of the IEEE 754.


1 Like

Thanks for you answer, what types should I use for Kotlin and SwiftUI

@Ciprian_Gabor: May I know which SDK you are using?


id("io.realm.kotlin") version "1.4.0"

That’s what I suspected earlier.

Currently, Kotlin SDK doesn’t support Decimal128 which is why you couldn’t find the type but would be available soon. With this said and considering this limitation I would use Double as they are more accurate when doing price calculations.

1 Like

Do you have any exact date when is going to be available?

Sorry, I don’t have an update regarding that.

1 Like