MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/t4kg4k/interview_with_senior_java_developer/hz3cs5o/?context=3
r/java • u/edmguru • Mar 01 '22
36 comments sorted by
View all comments
8
This is hilarious! Can someone explain the BigDecimal joke?
12 u/VincentxH Mar 02 '22 BigDecimal is a datatype often used when accurate decimal arithmetic needs to be performed, like with money.Using floating point primitives, like double, is a classic mistake. Because it leads to problems of floating point arithmetic inaccuracies.It's both a standard interview question and common mistake in the wild. 0 u/[deleted] Mar 02 '22 [deleted] 3 u/VincentxH Mar 02 '22 Yeah that lovely hack. Leading to problems like this with even an unsigned 32 bit int: https://www.google.com/amp/s/www.wsj.com/amp/articles/berkshire-hathaways-stock-price-is-too-much-for-computers-11620168548At least use a long these days.
12
BigDecimal is a datatype often used when accurate decimal arithmetic needs to be performed, like with money.
Using floating point primitives, like double, is a classic mistake. Because it leads to problems of floating point arithmetic inaccuracies.
It's both a standard interview question and common mistake in the wild.
0 u/[deleted] Mar 02 '22 [deleted] 3 u/VincentxH Mar 02 '22 Yeah that lovely hack. Leading to problems like this with even an unsigned 32 bit int: https://www.google.com/amp/s/www.wsj.com/amp/articles/berkshire-hathaways-stock-price-is-too-much-for-computers-11620168548At least use a long these days.
0
[deleted]
3 u/VincentxH Mar 02 '22 Yeah that lovely hack. Leading to problems like this with even an unsigned 32 bit int: https://www.google.com/amp/s/www.wsj.com/amp/articles/berkshire-hathaways-stock-price-is-too-much-for-computers-11620168548At least use a long these days.
3
Yeah that lovely hack. Leading to problems like this with even an unsigned 32 bit int: https://www.google.com/amp/s/www.wsj.com/amp/articles/berkshire-hathaways-stock-price-is-too-much-for-computers-11620168548
At least use a long these days.
8
u/uh-hum Mar 02 '22
This is hilarious! Can someone explain the BigDecimal joke?