bigdecimal Questions

21

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...
Threesome asked 30/3, 2023 at 2:48

8

I am using BigDecimal to get some price values. Requirement is something like this, what ever the value we fetch from database, the displayed valued should have 2 decimal points. Eg: fetched va...
Apologue asked 25/1, 2013 at 5:1

4

Solved

Initially code was : if(!Objects.equals(src.getApplicationItemCost(), dest.getApplicationItemCost())){ log.info("Difference") } Output: getApplicationItemCost: src:0.0| dest:0 Difference ...
Moses asked 12/2, 2020 at 6:47

6

Solved

After a series of calculations in my code, I have a BigDecimal with value 0.01954 I then need to multiply this BigDecimal by 100 and I wish the calculated value to be 1.95 I do not wish to perfor...
Blunk asked 17/6, 2014 at 20:36

7

Solved

How to extract a number after the decimal point using BigDecimal ? BigDecimal d = BigDecimal.valueOf(1548.5649); result : extract only : 5649
Jugal asked 30/4, 2012 at 12:3

12

Solved

I want to use assert between 2 two decimal, I use this: BigDecimal bd1 = new BigDecimal (1000); BigDecimal bd2 = new BigDecimal (1000); org.junit.Assert.assertSame (bd1,bd2); but the JUnit log s...
Durra asked 23/2, 2016 at 9:8

14

Solved

I have the following code in Java; BigDecimal price; // assigned elsewhere if (price.compareTo(new BigDecimal("0.00")) == 0) { return true; } What is the best way to write the if condition?
Autecology asked 8/6, 2012 at 14:36

7

Solved

I'm new to Java and trying to take a BigDecimal (for example 99999999.99) and convert it to a string but without the decimal place and trailing numbers. Also, I don't want commas in the number and ...
Nolanolan asked 22/8, 2009 at 20:19

3

Solved

Avro schemas are defined using JSON. Schemas are composed of primitive types (null, boolean, int, long, float, double, bytes, and string) and complex types (record, enum, array, map, union, and fix...
Wag asked 5/7, 2016 at 21:28

5

Solved

I came across two ways of getting BigDecimal object out of a double d. new BigDecimal(d) BigDecimal.valueOf(d) Which would be a better approach? Would valueOf create a new object? In general (not...
Slippy asked 25/8, 2011 at 6:54

8

Solved

I have to calculate some floating point variables and my colleague suggest me to use BigDecimal instead of double since it will be more precise. But I want to know what it is and how to make most o...
Adjudication asked 5/8, 2010 at 9:39

2

Solved

I have POJO like where I have a BigDecimal field: public class Foo implements Serializable { private BigDecimal amount; } I want to have the BigDecimal value up to 2 decimal place only. Is the...

2

Solved

Class BigDecimal has some useful methods to guarantee lossless conversion: byteValueExact() shortValueExact() intValueExact() longValueExact() However, methods floatValueExact() and doubleValue...
Mayor asked 1/12, 2019 at 8:30

5

Solved

Why does this code sometimes return 1E+1 whilst for other inputs (e.g. 17) the output is not printed in scientific notation? BigDecimal bigDecimal = BigDecimal.valueOf(doubleValue).multiply(BigDec...
Cyton asked 29/5, 2009 at 9:51

6

Solved

I'm using BigDecimal for my numbers in my application, for example, with JPA. I did a bit of researching about the terms 'precision' and 'scale' but I don't understand what are they exactly. Can a...
Elvyn asked 16/2, 2016 at 14:53

9

Solved

How can I compare if BigDecimal value is greater than zero?
Fibrillation asked 12/11, 2010 at 12:18

3

I have a Get API which returns a JSON. The format expected is: { "value1": "123.00", "value2": "23.00" } These values are BigDecimal in the object: public class Result{ BigDecimal value1; B...
Entrant asked 3/9, 2018 at 12:11

6

Solved

I have an XSD that requires me to use a BigDecimal for a lat/lon. I currently have the lat/lon as doubles, and convert them to BigDecimal, but I am only required to use about 12 places of precision...
Surfing asked 28/2, 2012 at 13:35

3

I followed the tutorial https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html, then I successfully create the folders of androidmain, iosmain and commonmain. However when I want to impl...
Infancy asked 22/3, 2019 at 9:39

9

Solved

In Java, I want to take a double value and convert it to a BigDecimal and print out its String value to a certain precision. import java.math.BigDecimal; public class Main { public static void m...
Ullage asked 12/9, 2012 at 19:50

7

Solved

What does Disconnected from the target VM, address: '127.0.0.1:51928', transport: 'socket' mean? This is my code: import java.math.BigDecimal; public class puzzle2 { public static void main(String...
Heptameter asked 8/1, 2018 at 17:29

1

Solved

I'm using Kotlin/JVM 1.8.0 and Kotlinx Serialization 1.4.1. I need to encode a java.math.BigDecimal and java.math.BigInteger to JSON. I'm using BigDecimal and BigInteger because the values I want t...
Harborage asked 27/1, 2023 at 11:55

22

Solved

I've been trying to convert a value of seconds (in a BigDecimal variable) to a string in an editText like "1 hour 22 minutes 33 seconds" or something of the kind. I've tried this: String ...
Leprous asked 25/5, 2011 at 2:32

2

I have a JSON seriliazer which serializes a BigDecimal in the way presented in this SO answer: public class MoneySerializer extends JsonSerializer<BigDecimal> { @Override public void serial...
Mikaelamikal asked 29/12, 2022 at 22:14

3

Example: public class Round { private static final BigDecimal TWELVE = new BigDecimal("12"); public static void main(String[] args) { BigDecimal annualAmt = new BigDecimal("55867.59"); BigDe...
Ezar asked 11/5, 2015 at 21:15

© 2022 - 2025 — McMap. All rights reserved.