Hacker News new | ask | show | jobs
by jonshea 5609 days ago
My understanding is that you are correct. I believe that BigDecimal.doubleValue() does the conversion by (wait for it…) converting to a string and parsing with Double.parseDouble(). Real quick:

scala> val y y: java.math.BigDecimal = 2.2250738585072012E-308

scala> y.doubleValue() Hangs

This is one of those “harder than it looks” problems.

1 comments

Yeah, I went back to my code and realized there was a precision problem I had to fix for numbers approaching 64-bit minimum. Once I fixed that issue, it went back to hanging again :(

I updated the post, and I'm looking for new alternatives now.

maybe its okay to lose some precision as everybody knows that doubles are already inaccurate? :)

http://en.wikipedia.org/wiki/Floating_point#Accuracy_problem...

edit: i mean: normalize(!), check if it is textually the bad magic number, then either use builtin conversion or use your solution. a? :)