Never use float or double for money. 💸
I tell this to my Java students quite early, and this video from Adam Bien is a nice example of why:
Of course, Java has BigDecimal, and that is often what you will find in real applications. But while teaching Java I usually prefer long / Long first.
12.34 € becomes 1234 cents.
It is simple, exact, and students do not have to learn BigDecimal while they are still trying to understand the basics of Java.
There is enough time later to make money complicated. 😅 What do you use for currencies in Java or the language you use?
#Java #Programming #SoftwareDevelopment
Never Use double for Money: 0.1 + 0.2 #java #shorts #coding #airhacks Never Use double for Money: 0.1 + 0.2 #java #shorts #coding #airhacks
youtube.com
Kommentieren und diskutieren können Sie direkt unter dem Beitrag auf LinkedIn.