I have an address domain , which has fields lat and long as BigDecimal and i am using constraints of scale as 16. I have this address
550 Tremont St, Boston, MA 02116, USA
its long and lat are -71.07126540000002 and 42.3438919
Longitude for this address is stored in db as -71.0712654000000200. now i need to compare the saved longitude with any new request to check if longitude already exist.
I am sending the same longitude again -71.07126540000002 but i am not able to convert it the form as it saved in db (-71.0712654000000200) before comparing as they are the long. of same address.
i tried using
BigDecimal a = new BigDecimal(-71.07126540000002)
println a.setScale(16, RoundingMode.CEILING)? // tried all other RoundingMode
but all are giving response as either -71.0712654000000156 or -71.0712654000000157 but not getting -71.0712654000000200
Help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…