Skip to main content

Timeline for How to overcome inaccuracy in Java

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
May 23, 2017 at 12:08 history edited URL Rewriter Bot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Mar 5, 2014 at 5:39 vote accept Hungry Blue Dev
Mar 5, 2014 at 5:32 answer added keshlam timeline score: 2
Mar 5, 2014 at 5:29 comment added Hungry Blue Dev @user2864740 thanks, i'll see to it.
Mar 5, 2014 at 5:29 comment added user2864740 The only immediate solution I can think of is to special-case the input before calling tan. If it's "close enough to PI/2" for your liking, simply return Inf/-Inf (or whatever you are expecting) instead of calling tan. If you need to do "trigonometrical correct" math, there may be a library that can can deal with the exact mathematical concepts. (I think "symbolic math" may be a useful search term).
Mar 5, 2014 at 5:24 comment added Hungry Blue Dev @user2864740 Thanks, that tells me why... But can u tell me how to fix it?
Mar 5, 2014 at 5:22 comment added user2864740 See tan(PI/2) for why you don't get Infinity. However, I don't know of a way to get tan to "accept values close to PI/2" as PI/2, and all the environments seem to produce a value.
Mar 5, 2014 at 5:18 comment added user2864740 theta isn't exactly half-pi, which is why there is no Infinity in the output - NaN/InF is not "stored as" 1.633123935319537E16, which is still a finite number.
Mar 5, 2014 at 5:18 answer added yshavit timeline score: 4
Mar 5, 2014 at 5:14 answer added Florent Bayle timeline score: 3
Mar 5, 2014 at 5:07 history asked Hungry Blue Dev CC BY-SA 3.0