Performance Analysis of BigDecimal Arithmetic Operation in Java

The Java programming language provides binary floating-point primitive data types such as float and double to represent decimal numbers. However, these data types cannot represent decimal numbers with complete accuracy, which may cause precision errors while performing calculations. To achieve bette...

Full description

Bibliographic Details
Main Authors: Jos Timanta Tarigan, Elviawaty M. Zamzami, Cindy Laurent Ginting
Format: Article
Language:English
Published: ITB Journal Publisher 2018-12-01
Series:Journal of ICT Research and Applications
Subjects:
Online Access:http://journals.itb.ac.id/index.php/jictra/article/view/7278
Description
Summary:The Java programming language provides binary floating-point primitive data types such as float and double to represent decimal numbers. However, these data types cannot represent decimal numbers with complete accuracy, which may cause precision errors while performing calculations. To achieve better precision, Java provides the BigDecimal class. Unlike float and double, which use approximation, this class is able to represent the exact value of a decimal number. However, it comes with a drawback: BigDecimal is treated as an object and requires additional CPU and memory usage to operate with. In this paper, statistical data are presented of performance impact on using BigDecimal compared to the double data type. As test cases, common mathematical processes were used, such as calculating mean value, sorting, and multiplying matrices.
ISSN:2337-5787
2338-5499