java doubleinfinity_将Double转换为BigDecimal时获取NaN / Infinity错误 (Getting NaN / Infinity Error when conve...

2015-03-23 15:31:07

0

So I have this division between doubles (from values it gets in a database);

indPayRatio[loadCounter] = c.getDouble(c.getColumnIndex("payment")) / c.getDouble(c.getColumnIndex("debt_total"));

There is no case where either of the values can be blank. They HAVE to be something here.

Well I get this crazy long number sometimes, so I convert it to BigDecimal like so:

bdRatio = new BigDecimal(indPayRatio[i]);

At this line, I get the following stack trace from many users. I am unable to replicate it so I am unsure of the value.

java.lang.RuntimeException: An error occured while executing doInBackground()

at android.os.AsyncTask$3.done(AsyncTask.java:300)

at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)

at java.util.concurrent.FutureTask.setException(FutureTask.java:222)

at java.util.concurrent.FutureTask.run(FutureTask.java:242)

at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

at java.lang.Thread.run(Thread.java:841)

Caused by: java.lang.NumberFormatException: Infinity or NaN: NaN

at java.math.BigDecimal.(BigDecimal.java:465)

at com.---.---.DebtDataSource.payoffDebt(DebtDataSource.java:544)

at com.---.---.PlannerFragment$PlannerTask.doInBackground(PlannerFragment.java:177)

at com.---.---.PlannerFragment$PlannerTask.doInBackground(PlannerFragment.java:143)

at android.os.AsyncTask$2.call(AsyncTask.java:288)

at java.util.concurrent.FutureTask.run(FutureTask.java:237)

... 4 more

My first hunch, is that I should be using BigDecimal to multiply at the first line, but if that is the issue, why am I getting the error when I convert it to BigDecimal?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值