Giter VIP home page Giter VIP logo

bigdecimal's Introduction









✖︎ Arithmetic operations in BigDecimal made easier

See Big Decimal wiki

Why?

  • No big deal working with BigDecimal operations
  • Clean and focused
  • Actively maintained

Dependency Information

Download the latest version JAR to include it in your project

Maven

<dependency>
        <groupId>com.abranhe.bigdecimal</groupId>
        <artifactId>bigdecimal</artifactId>
        <version>1.0.1</version>
</dependency>

Gradle/Grails

compile 'com.abranhe:bigdecimal:1.0.1'

Grape

@Grapes(
    @Grab(group='com.abranhe', module='bigdecimal', version='1.0.1')
)

Ivy

<dependency org="com.abranhe" name="bigdecimal" rev="1.0.1"/>

Using on your project

import com.abranhe.bigdecimal.Operations;

Usage

Example 1

import com.abranhe.bigdecimal.Operations;
import java.math.BigDecimal;

public static void main(String[] args){

        BigDecimal x = new BigDecimal("124567890.0987654321");
        BigDecimal y = new BigDecimal("987654321.123456789");

        System.out.println(Operations.add(x, y));
        //=> 1112222211.2222222211
}

Example 2

import java.math.BigDecimal;

public static void main(String[] args){

        BigDecimal x = new BigDecimal("124567890.0987654321");
        BigDecimal y = new BigDecimal("987654321.123456789");

        Operations o = new Operations();
        System.out.println(com.abranhe.bigdecimal.Operations.divide(x, y));
        //=> 0.12613
}

Example 3

import com.abranhe.bigdecimal.Operations.divide;
import java.math.RoundingMode;
import java.math.BigDecimal;

public static void main(String[] args){

        BigDecimal x = new BigDecimal("124567890.0987654321");
        BigDecimal y = new BigDecimal("987654321.123456789");

        System.out.println(divide(x, y, 9, RoundingMode.FLOOR));
        //=> 0.126124988
}

API

Addition

Add two BigDecimal numbers

public static BigDecimal add(BigDecimal x, BigDecimal y);

Parameters:

  • x - Big decimal number
  • y - Big decimal number

Returns:

Addition of x plus y

Subtraction

Add two BigDecimal numbers

public static BigDecimal subtract(BigDecimal x, BigDecimal y);

Parameters:

  • x - Big decimal number
  • y - Big decimal number

Returns:

Subtraction of x minus y

Multiplication

Multiplication between two BigDecimal numbers

public static BigDecimal multiply(BigDecimal x, BigDecimal y);

Parameters:

  • x - Big decimal number
  • y - Big decimal number

Returns:

Multiplication of x times y

Division

Division between two BigDecimal numbers

public static BigDecimal divide(BigDecimal x, BigDecimal y, int scale, RoundingMode roundingMode);

Parameters:

  • x - Big decimal number
  • y - Big decimal number
  • scale - Scale of the BigDecimal quotient to be returned
  • roundingMode - Rounding mode to apply

Returns:

Division of x by y

Default Division

Division between two BigDecimal numbers

public static BigDecimal divide(BigDecimal x, BigDecimal y);

Parameters:

  • x - Big decimal number
  • y - Big decimal number

Default

  • scale - 5
  • roundingMode - CEILING

Returns:

Division of x by y

Team

Carlos Abraham Logo
Carlos Abraham

License

MIT License © Carlos Abraham

bigdecimal's People

Contributors

abranhe avatar ezner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bigdecimal's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.