Reputation: 16308
I'm using the Apfloat library of version 1.8.3
During my computation i need to calculate value of pi with appropriate precision. At the moment i'm using ApfloatMath.pi
method and the code looks like this
object Problem461 extends App {
val Pi = ApfloatMath.pi(200)
During unit test i'm receiving NullPointerException since ApfloatMath.pi
is returning null
. I have tried many things, set different precisions, including Apcomplex.DEFAULT, and tried to create apfloat.properties resource bundle but result of ApfloatMath.pi
is still null
.
How i supposed to use this method?
UPDATE
I have just solved this issue by declaring Pi
as lazy val
:
lazy val Pi = ApfloatMath.pi(100)
Also i've made sure Pi
is calculated correctly as simple val
during just plain run, not unit test.
So main question changes to:
What could be uninitialized in the apfloat lib during val
calculaction at the moment of unit test?
Upvotes: 2
Views: 108