Questions tagged [bigdecimal]

BigDecimal is a numeric object type in Java that represents decimal numbers with arbitrary precision.

Because double and float use a fixed amount of memory (64 and 32 bits respectively), they have limited precision which can lead to rounding errors, and more importantly, they cannot be used to represent all decimal fractions exactly as they use two's complement.

BigDecimal solves these problems by providing arbitrary precision and by using a decimal representation of their values.

The BigDecimal class also provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion.

More information can be found in the BigDecimal Javadoc

1677 questions
0
votes
0 answers

JavaFX, initialize setCellValueFactory for TableView with bean and bigDecimal, result -> NullPointerException

i'm new to JavaFX and i want to print some BigDecimal and Bean in TableColumn in my TableView. The issue is that i get a NullPointerExceptionexception when i try to setItems of the TableView. Just to be clear i'm using the fxml with scenario builder…
0
votes
1 answer

BIgDecimal alternative like stringBuilder

Analog of StringBuilder for BigDecimal I checked this link already but i am running sonar and it gives critical error for below lines: ..... BigDecimal total = new BigDecimal(0); for (int loop = 0; loop <= 30; loop++) { switch (loop) { …
0
votes
2 answers

What is the number of significant digits that BigDecimal is allowing to use - Java

My application is using a double in Java for representing floating point numbers. double has a limitations of 17 significant digits. we are considering to refactor the code to use BigDecimal - however i couldn't find any information in the…
Oren Levi
  • 63
  • 7
0
votes
0 answers

How can I find the logarithm of a BigDecimal type

I have a series of probabilities p1, p2, p3, p4, and I need to transform each one to a logarithmic scale to make comparisons. This is easy to do with int datatypes, but I am using BigDecimal because I need precision, and I can't find a way to do…
traderjosh
  • 321
  • 5
  • 16
0
votes
1 answer

How to show BigDecimal number as human readable when using ActiveSupport::TestCase

When I'm using ActiveSupport::TestCase tests that are failed shows message like this: 2) Failure: ArrayTest#test_example [/Users/ironsand/dev/my_project/test/core_ext/array_test.rb:6]: --- expected +++ actual @@ -1 +1…
ironsand
  • 14,329
  • 17
  • 83
  • 176
0
votes
0 answers

Use of Bigdecimal while validation epoch expoential timestamp

I have some phone records in which epoch time is coming in exponential format like 1467.738871E9. I need to validate those records in which number is not in proper format and drop those records.Right now, I am using big decimal,but I have heard that…
mahan07
  • 887
  • 4
  • 14
  • 32
0
votes
1 answer

Counting standard deviation from parsed XML file

I wrote a method that counts average of sell currency exchange-course(ASK) and standard deviation of it , but i think that it isn't the easiest way to define such behavior so i need a help . In my opinion there is too much creating Bigdecimal…
0
votes
1 answer

Avoid floating point precision issue using java.math.BigDecimal

I have a matrix populated by double values (from 0 to 1). For convenience, let's talk about rows and columns. I want to normalize the double values of the matrix, so that the sum of all the rows, for each columns, returns 1. This task triggers a…
Roberto
  • 243
  • 1
  • 5
  • 15
0
votes
0 answers

Adding up Currency Values in a JavaFX table using BigDecimal

I want to sum the ObjectProperty values of a JavaFX TableColumn. I've used this question as a reference. The problem is my implementation of it as shown here: private void doSalesTotals() { olSales.addListener(new…
MusH
  • 85
  • 2
  • 9
0
votes
0 answers

Save BigDecimal in jpa

I use spring jpa and hibernate 4 for the implementation. In a object, I have a bigDecimal field. Before saving this field, I see the value: 0.09975. When it's saved in mariadb, the value is 0.10. In my objet private BigDecimal tvqRate; Jpa have…
bernard deromme
  • 151
  • 2
  • 3
  • 19
0
votes
0 answers

How to use the BigDecimal classes in C#?

I don't need the big integer class. I only need BigDecimal as I am working on very big decimals right now. Here is a link which I got the source code from, but it only contains BigInteger and BigFloat. I only need to work with addition, subtraction,…
0
votes
1 answer

Long vs. BigInteger

As I understand, I can abstract the precision away using the Number interface, which has Integer, Long and BigInteger implementations and plug the type I need depending on the range of my values. I understand the BigInteger is not ubiquitous because…
Little Alien
  • 1
  • 8
  • 22
0
votes
0 answers

How to convert the values of all element of ArrayList double to BigDecimal?

I have some ArrayList and I want to convert the values of all element of those ArrayList into BigDecimal because double datatype produce unprecise result. I use temporary variable to store the result of the calculation the I assign the values of…
0
votes
1 answer

Change 6.51 to 6.50 in java BigDecimal

Here it is what we have tried but none of those things work... BigDecimal Total_Discount=new BigDecimal(10.00); BigDecimal Amount_To_User=new BigDecimal(00.00); BigDecimal Amount_To_Me=new BigDecimal(00.00); …
Gopi Lal
  • 417
  • 5
  • 23
0
votes
1 answer

Rounding with BigDecimal?

I have been trying to round using bigdecimal in java and have been running into a java.lang.ArithmeticException error that is showing Non-terminating decimal expansion. Can anyone explain the origins of the error as I am pretty new to java? and help…
TheLiquor
  • 71
  • 7