S
Stefan Ram
I admit that I actually do not know what I am doing,
possibly someone can explain this to me.
I wanted to use »java.math.BigDecimal« for some calendar
calculations so as to never have to worry again about any
limitations.
Eventually, it all worked, but I have a loop, where I
keep incrementing certain dates based on previous calculations.
BigDecimal tries to keep track not only of the values, but
also of their precision. A certain variable I use in the loop,
will take values as follows in some cases (simplified):
1.0
2.00
3.000
4.0000
5.00000
6.000000
7.0000000
...
This means, that the loop will become slower and slower
and eventually stop due to lack of memory for all those »0«.
No, my naïve idea is to add a step to my date package where
I do what a human would do when calculating with a pencil:
discard all the trailing »0« from the results of my
BigDecimal calculations.
But from the point of numerical mathematics, what am I doing,
when I am doing this?
Is it a mistake to do this?
Has anyone else already had this effect and are there other or
better solutions for it?
possibly someone can explain this to me.
I wanted to use »java.math.BigDecimal« for some calendar
calculations so as to never have to worry again about any
limitations.
Eventually, it all worked, but I have a loop, where I
keep incrementing certain dates based on previous calculations.
BigDecimal tries to keep track not only of the values, but
also of their precision. A certain variable I use in the loop,
will take values as follows in some cases (simplified):
1.0
2.00
3.000
4.0000
5.00000
6.000000
7.0000000
...
This means, that the loop will become slower and slower
and eventually stop due to lack of memory for all those »0«.
No, my naïve idea is to add a step to my date package where
I do what a human would do when calculating with a pencil:
discard all the trailing »0« from the results of my
BigDecimal calculations.
But from the point of numerical mathematics, what am I doing,
when I am doing this?
Is it a mistake to do this?
Has anyone else already had this effect and are there other or
better solutions for it?