Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
70 views

How to convert a scientific notation string to normal string

I have a below program which is reading and displaying decimal numbers. import java.math.*; import java.text.DecimalFormat; import java.text.ParseException; public class Main { public static void ...
RandomGuy's user avatar
  • 127
-1 votes
4 answers
107 views

Split Java BigDecimal into smaller BigDecimal adding up the original value [closed]

Is there a way or apache utils function to split a BigDecimal number into random n smaller BigDecimals. I am looking to have this function for creating test data various combinations for a provided ...
dude_in_london's user avatar
0 votes
1 answer
23 views

Parsing long decimals in Fixedwidth file schema

I have a requirement for parsing a fixedwidth file containing large decimals using MuleSoft. Here's a sample: 000GX0TEM PHN 001GX0TEM 00001 002GX0TEM ...
Christine Smith's user avatar
0 votes
1 answer
49 views

Format number to decimal in php

I am sending data by api with json response where it has amount filed. it is required that amount should be decimal with 2 zeros after the point like this 400.00 and it should not be a string. I am ...
Sahak's user avatar
  • 1
0 votes
2 answers
156 views

How to test if a BigDecimal object is divisible by another BigDecimal in Java?

I'm working on a problem from a Java textbook which asks to find the first 10 numbers with 50 decimal digits that are divisible by 2 or 3. Here is my code: import java.math.*; public class Divisible {...
Osmium's user avatar
  • 179
4 votes
2 answers
127 views

Which Data Type should I use for Handling an ERP: BigDecimal or Double in Java?

I am currently developing an ERP (Enterprise Resource Planning) system and need to make decisions regarding the type of data to use for handling calculations and other numerical values within the ...
dssof's user avatar
  • 299
2 votes
1 answer
109 views

BigDecimal - How to know the precision in small decimal numbers below 1 considering left zeroes just after comma

I am developing a calculator and I want to format the number in scientific notation only when it reaches a certain number of digits. I wrote this piece of code which works fine for big numbers. ...
Fausto Odilon's user avatar
1 vote
2 answers
64 views

How can I convert the decimal values in a BigDecimal to Zero always in java

Example. Input: 4066508.33 output : 4066508.00 Tried DecimalFormat decimalFormat= new DecimalFormat("#.00"); decimalFormat.format(num)) also String.format("%.2f", num)); Both ...
user24385792's user avatar
0 votes
0 answers
57 views

why Java BigDecimal giving Precision Errors

i am using java big decimal. but still i am not getting expected result.. public class DecimalAdjustEx { public static void main(String[] args) { BigDecimal v1 = new BigDecimal("100&...
srikanth m's user avatar
2 votes
1 answer
67 views

Formatting very large numbers to local settings in javascript

I saw the question here How can I format big numbers with toLocaleString? but this doesn't exactly answer the questino I have. I'm using the library provided by https://github.com/royNiladri/js-big-...
Aram Papazian's user avatar
0 votes
0 answers
44 views

Java Scanner nextBigDecimal throwing InputMismatchException exception

I wrote some simple Java code to take input from the console (using Eclipse 2016 IDE) to assist with iterating through a text file and outputting a file in SWIFT MT940 statement structure. For the ...
GuzziTony's user avatar
0 votes
1 answer
89 views

Calculate an expression in java which is accurate upto 19 digits

I have an expression in string for example formula="333333333333333333+222222222222222222" I am trying to calculate the value of the expression to be accurate upto 18 digits. to calculate I ...
akaparadox's user avatar
-1 votes
1 answer
51 views

Big decimal with generic class [duplicate]

incompatible bounds compilation error public class Complex<T extends BigDecimal, R extends BigDecimal> { private T r; private R i; public Complex(T r, R i) { this....
Khaled Osama's user avatar
3 votes
1 answer
3k views

Why is RoundingMode is not resolving in Java 21? [closed]

I am trying to work through a Spring lab and when I try to pull in Java 21, RoundingMode is not resolving. I have been trying to research what I am doing wrong but I'm not finding anything seems to ...
Will Lied's user avatar
-3 votes
1 answer
118 views

How to round BigDecimal money calculations in Java to 2 decimal places using the best RoundingMode? [closed]

Suppose I have a BigDecimal amount and another BigDecimal tax. I want to perform the following calculation : amountWithoutTax = amount - tax amount and tax are supposed to be in the format YYYY.XX (i....
user1068636's user avatar
  • 1,929
0 votes
1 answer
169 views

How do I use the extension functions for BigDecimal in kotlin?

As I understand it, Kotlin has operator overloading for BigDecimal instances. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/java.math.-big-decimal/ Why can't I actually use it in my program ? Is ...
Harsha Limaye's user avatar
2 votes
2 answers
69 views

Delphi IEEE754 (80) binary to Java Bigdecimal

We have two teams, the Delphi team and the Java team. Delphi is based on TExtended80Rec in Delphi 11, which is stored in the sqlite database and saved as a binary stream. I have tried using Java to ...
xinle shan's user avatar
0 votes
0 answers
39 views

BigDecimal in ObjectNode getting rounded when storing in database

I am storing ObjectNode and the objectNode is the object of a class which contains a BigDecimal attribute, when we store a big number in the ObjectNode and store that ObjectNode in the postgress, the ...
Ankita Deep's user avatar
0 votes
0 answers
45 views

Spring Data JPA takes longer to persist entity with BigDecimal datatype

I have a spring project that uses Spring data JPA and the entity looks like below @Getter @Setter @SuperBuilder @NoArgsConstructor @Entity public class FinancialDetail extends BaseTransactionalEntity {...
Mohammed Rashid's user avatar
-4 votes
1 answer
320 views

Java double converts more than 4 decimal points to exponential format and stores the same exponential format in the DB

I have an entity class(Account) wherein I have the following property @Column(name = "balance", precision = 10, scale = 10, nullable = false) Double balance; Then in one of my spring ...
nickgkd's user avatar
  • 57
1 vote
2 answers
61 views

Precision Error while converting dollars/gallon to dollars/liter and back

The following code has a precision error but I'm at a loss as to how to resolve it. Given an initial value set in dollar/gal of $3.95, when change the ChoiceBox to "dollars/liter" I get $1....
JimArkadian's user avatar
1 vote
0 answers
99 views

Optimize BigDecimal in java

In a web application I concerned, there is a blizzard of BigDecimal operations. Is there any way to optimize this in both memory footprint and cpu util? I want to write some specific implementations ...
onRiv's user avatar
  • 163
0 votes
2 answers
298 views

How Can I Create A BigDecimal Object that has null as it's value

I have a java program that I am testing and a lot of the code is centered around the idea that a coin can have a value null. The issue, the coin is defined using Coin(BigDecimal) and I cannot figure ...
user avatar
-2 votes
2 answers
125 views

How to format a BigDecimal without losing trailing fraction zeros?

NumberFormat doesn't seem to care about the scale of a BigDecimal, so given tailing zeros are lost: NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN); nf.setMaximumFractionDigits(Integer....
Knight Industries's user avatar
0 votes
1 answer
286 views

How to implement Excel MROUND() function in Java using BigDecimal instead of double

How can I round to a specific multiple in Java? In excel there is the mround function which allows for easy rounding to a specified multiple like so: mRound(variable,multiple) e.g. This is how the ...
sameer59's user avatar
1 vote
3 answers
112 views

BigDecimal stripTrailingZeros and equality

Given BigDecimal a = ...; BigDecimal b = ...; Do the following hold for all possible values of a and b? if (a.compareTo(b) == 0) assert a.stripTrailingZeros().equals(b.stripTrailingZeros()) if (a....
Klitos Kyriacou's user avatar
2 votes
1 answer
188 views

Does BigDecimal division have a shortcoming when the scale is known?

First of all, I should clarify that I'm asking this question only for enlightenment; I'm not desperate for an answer, but an answer might help me appreciate the BigDecimal class more. I always had - ...
Aaron Bitman's user avatar
0 votes
1 answer
104 views

Questions about BigDecimal multiply() method in Java

I've been trying to avoid precision loss in case of using BigDecimal multiply() method in Java. Please check an example code below. import java.math.BigDecimal; import java.text.DecimalFormat; import ...
yoyoyoni1004gmailcom's user avatar
-1 votes
1 answer
58 views

How to add more than two BigDecimals fields to calculate the sum in a By Collector grouping

This is my method where I group the values ​​and perform a sum of all the outstanding balances of the client. But I have two more values, which I need to calculate the sum: BigDecimal ...
jorge jesus achulla palacios's user avatar
2 votes
0 answers
161 views

How to format scientific E notation into human readable numbers? (numbers larger than BigDecimal)

I'm trying to create a number class which can hold values from 4.9E-324e-1.7976931348623157E308 to 1.7976931348623157E308e1.7976931348623157E308 in both signs. (yes, the exponent is also a double) My ...
LXIV's user avatar
  • 21
3 votes
2 answers
192 views

Java "incompatible types" error with Comparator.comparing(BigDecimal::new).reversed()

I'm working on a problem where you are given a String[] containing numbers that are all formatted differently - e.g. "9", "-100", "56.6", "0.12", ".12"...
Grey's user avatar
  • 31
0 votes
1 answer
54 views

BigDecimalRange validator is not working in vaadin 8 (Binder)

BigDecimalRange validator is not working in vaadin version 8.4.3 we tried to change to the latest version of vaadin 8 but the problem persist . Error shows withValidator like renaming the file ,What ...
Archana's user avatar
0 votes
0 answers
26 views

How do I fix the conversion problem to the DecimalNumberWithString function?

I have a problem with converting NSString to NSDecimalNumber. NSLog(@"calcuMax_test - calculateMaxForCross feeRateDecimal: --------------------------------------------------------------------ㅍ&...
won's user avatar
  • 73
0 votes
2 answers
114 views

How to judge whether the BigDecimal division operation is indivisible in Java?

When we do arithmetic, we often keep the whole decimal if we can divide it completely, and we have to keep a few decimal places if we can't divide it completely.At present, BigDecimal either chooses ...
feilong gao's user avatar
0 votes
2 answers
1k views

Do I need to have an additional validation for a BigDecimal to check if it is a number and not any string in Java?

I'm working on a Rest API in Java and Spring Boot and I have a POST request and it contains a request body, an object RequestCustomer and one of the field is of type BigDecimal. I need to do a regex ...
elvis's user avatar
  • 1,078
0 votes
1 answer
83 views

BigDecimal division precision using string converted to BD

I am trying to convert string values into BigDecimal and then perform my calculation, but the output is not as expected. Please find the code below: import java.math.BigDecimal; import java.math....
Ranit Das's user avatar
0 votes
1 answer
76 views

Why BigDecimal.Zero exist in Java where as Double.zero doesn't

I am curious to understand why do we see BigDecimal.Zero but not Double.Zero, so if we need to assign a double variable as Zero then we need to cast it to (double) 0. Any specific reasons creators ...
Raj Saraogi's user avatar
  • 1,898
-1 votes
2 answers
198 views

Different behaviour of Java BigDecimal.doubleValue() when 14 o 15 decimals

Can someone explain me why BigDecimal.doubleValue() gives me such results: BigDecimal bd1 = new BigDecimal("38.399999999999999"); //15 decimals double dd1 = bd1.doubleValue(); dd1 - > 38....
lospalos's user avatar
1 vote
3 answers
236 views

convert string to float considering all types of decimal separators

I tried to create a function in java which can convert a string to float considering commas and point as decimal separators and thousand separator can be space, point or commas. For example “998,4” ...
Amalia Muresan's user avatar
1 vote
3 answers
893 views

Facebook warm up challenge that I can't seem to figure out - Battleship

I am working on this MetaCareers code challenge (needs an account): You're playing Battleship on a grid of cells with 𝑅 rows and 𝐶 columns. There are 0 or more battleships on the grid, each ...
leftnut's user avatar
  • 61
1 vote
4 answers
357 views

Round decimals up to multiples of 5 with BigDecimal

I want to round BigDecimal decimal part according to the following rules: 1710.10 becomes 1710.10 1710.11 becomes 1710.15 1710.15 becomes 1710.15 1710.16 becomes 1710.20 I tried this way new ...
Carla C's user avatar
  • 189
0 votes
2 answers
244 views

How do i give a BigDecimal variable a value in a method?

Like the title says im trying to give the BigDecimal Variable a value of zero "(0)" or any other number in a method. I know that local variables in a method dont have a default value unlike ...
MasterSteve's user avatar
0 votes
0 answers
214 views

Retrieving a Decimal field from Db2 using JDBC

I am trying to retrieve STDDEV of a decimal value from Db2 for z/OS table. I use the below SQL. // Execute a query and generate a ResultSet instance rs = stmt.executeQuery(&...
Jaya sakthivel's user avatar
1 vote
3 answers
116 views

Why does this Pi approximation become less accurate?

The code included below calculates a pi approximation in Java using a Monte Carlo method. As expected, the answer (very) gradually improves, but when the main loop terminates the answer is always ...
Andrew Davison's user avatar
72 votes
22 answers
122k views

504 (Outdated Optimize Dep) while using react-vite

I installed a package called big decimal js while using React with JavaScript on Vite. On compiling, it showed the following error on the console, and the application did not load: My package.json: { ...
Vedant Shah's user avatar
  • 1,149
0 votes
1 answer
64 views

Round to 2 decimal places in Java using DecimalFormat

I am using DecimalFormat to round a value(in Double type) to 2 decimal places var decimalFormat = new DecimalFormat("0.0"); decimalFormat.setRoundingMode(RoundingMode.HALF_UP); decimalFormat....
Mr.Simple's user avatar
3 votes
1 answer
67 views

Issues with bigdecimal

I am trying to calculate leaseRate which is a big decial, However I receive the following error: Non-terminating decimal expansion; no exact representable decimal result I see that this is round issue,...
jennifer ruurs's user avatar
0 votes
1 answer
84 views

How do I use a BigDecimal from Scala.js in my JavaScript application?

I have this Scala object: @JSExportTopLevel("Calculator") object Calculator { @JSExport def calculate(): BigDecimal = 3.14 } I can call the exported singleton method from my JavaScript ...
Big McLargeHuge's user avatar
0 votes
2 answers
856 views

BigDecimal from json loses precision

The network call shows that the backend is sending this: "uom" : "EA", "qty" : 1.123456789012345678 but when it reaches the frontend, using console.log: { qty: 1....
Han's user avatar
  • 63
0 votes
0 answers
123 views

Java BigDecimal divide and multiply with same no does not give correct result

I am puzzled by Java Bigdecimal behavior. Let's say I have dividend = 3 and divisor = 23. first divide 3/23 = 0.130434783 Once I multiply 0.130434783 * 23 I should get 3. Bigdicimal gives a different ...
Varun's user avatar
  • 4,442

1
2 3 4 5
35