Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,939 questions

51,876 answers

573 users

How to use BigDecimal class in Java

2 Answers

0 votes
import java.math.BigDecimal;

public class MyClass {
    public static void main(String args[]) {
        BigDecimal a = new BigDecimal(99822838328382343.0);
        BigDecimal b = new BigDecimal(5.0);
        BigDecimal result = a.multiply(b); 
        
        System.out.println(result);
    }
}


/*

run:

499114191641911680

*/

 



answered Jul 25, 2019 by avibootz
0 votes
import java.math.BigDecimal;

public class MyClass {
    public static void main(String args[]) {
        BigDecimal a = new BigDecimal(3.0);
        BigDecimal b = new BigDecimal(5.5);
        BigDecimal result = a.divide(b, 10, BigDecimal.ROUND_UP);
        
        System.out.println(result);
    }
}


/*

run:

0.5454545455

*/

 



answered Jul 25, 2019 by avibootz

Related questions

1 answer 106 views
106 views asked Jul 24, 2022 by avibootz
1 answer 133 views
133 views asked Nov 2, 2016 by avibootz
2 answers 97 views
1 answer 94 views
1 answer 91 views
1 answer 81 views
81 views asked Jun 3, 2024 by avibootz
1 answer 107 views
...