Reputation: 1224
I want to do some calculation in my app where i divide two value lets say A and B. Some time A and B value are 0.0 and 0.0 respectively at that time i Get the output as NaN
(While debugging the code) and also on Toast
, But when i insert the value in sqlite db
there is nothing but the blank field is inserted, why is like that can anyone explain please. NOTE: my db field is double type. thanks
Upvotes: 0
Views: 461
Reputation: 8201
Try to validate the NaN
in android, use Double.isNaN(a/b)
. It will return true, when the argument is NaN
and false in all valid division operations.
Upvotes: 1
Reputation: 152867
Internally sqlite stores NaN values as NULL. It makes sense because in computational expressions, a NaN or NULL makes the whole expression NaN or NULL.
If you want to store a NaN explictly, you can store 'NaN'
as text for example.
Upvotes: 1