# bigdecimal

BigDecimal is a programming-language numeric type or library class that provides arbitrary-precision decimal arithmetic, including operations for arithmetic, rounding, comparison, and scale manipulation.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## How to Round Numbers in Python

DevFeed: [How to Round Numbers in Python](<https://devfeed.tech/articles/how-to-round-numbers-in-python-89666.md>)

Original publisher: [Read original article](<https://realpython.com/python-rounding/>)

Author: David Amos

Published: 2026-10-18T14:00:00Z

Content type: tutorial

Language: en

Sources: [Real Python](<https://devfeed.tech/sources/real-python.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [bigdecimal](<https://devfeed.tech/topics/bigdecimal.md>), [pandas](<https://devfeed.tech/topics/pandas.md>), [floating-point](<https://devfeed.tech/topics/floating-point.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [numpy](<https://devfeed.tech/tags/numpy.md>), [pandas](<https://devfeed.tech/tags/pandas.md>), [python](<https://devfeed.tech/tags/python.md>)

### AI overview

This tutorial explains Python's built-in rounding behavior, including its round-half-to-even rule, and shows how rounding choices can affect data and introduce bias. It demonstrates alternative rounding strategies, exact decimal arithmetic with Python's decimal module, and rounding values in NumPy arrays and pandas objects.

### Source excerpt

Learn how Python's round() works, why it rounds 2.5 to 2, and how you can manage rounding errors with decimal, NumPy, and pandas.

## double, BigDecimal, or Fixed-Point?

DevFeed: [double, BigDecimal, or Fixed-Point?](<https://devfeed.tech/articles/double-bigdecimal-or-fixed-point-18917.md>)

Original publisher: [Read original article](<https://blog.frankel.ch/bigdecimal-vs-double/>)

Author: Stefano Fago

Published: 2026-06-14T00:00:00Z

Content type: article

Language: en

Sources: [Nicolas Fränkel](<https://devfeed.tech/sources/nicolas-frankel.md>)

Topics: [bigdecimal](<https://devfeed.tech/topics/bigdecimal.md>), [floating-point](<https://devfeed.tech/topics/floating-point.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [bigdecimal](<https://devfeed.tech/tags/bigdecimal.md>), [financial](<https://devfeed.tech/tags/financial.md>), [fixed](<https://devfeed.tech/tags/fixed.md>), [floating-point](<https://devfeed.tech/tags/floating-point.md>), [ieee](<https://devfeed.tech/tags/ieee.md>), [java](<https://devfeed.tech/tags/java.md>), [money](<https://devfeed.tech/tags/money.md>), [performance](<https://devfeed.tech/tags/performance.md>), [precision](<https://devfeed.tech/tags/precision.md>), [rules](<https://devfeed.tech/tags/rules.md>)

### AI overview

Choosing Java's numeric type for money depends on required precision, rounding rules and performance; the excerpt rejects blanket rules to always use BigDecimal, floating point or fixed point. Java float and double use binary IEEE 754 representations, so many decimal values are approximate, a design tradeoff that suits some numerical work. The excerpt identifies direct equality checks as a common bug and recommends absolute tolerance for values in a known range, or relative tolerance when magnitudes vary widely. It notes that the appropriate tolerance depends on the data, and the excerpt ends as it begins to discuss financial rounding at display boundaries.

### Source excerpt

There is an evergreen debate in the Java world: should you always use BigDecimal for money? The short answer is no. The real answer is: it depends on your computational context: the precision you need, the rounding rules you must follow, and the performance budget you have. The problem is that this conversation is often driven by dogma rather than engineering.

## Adding Decimal Types to Rails Migrations

DevFeed: [Adding Decimal Types to Rails Migrations](<https://devfeed.tech/articles/adding-decimal-types-to-rails-migrations-28246.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2019/11/18/adding-decimal-types-to-rails-migrations.html>)

Author: Fuzzygroup

Published: 2019-11-18T00:00:00Z

Content type: article

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Ruby on Rails](<https://devfeed.tech/topics/ruby-on-rails.md>), [bigdecimal](<https://devfeed.tech/topics/bigdecimal.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [active-record](<https://devfeed.tech/tags/active-record.md>), [migrations](<https://devfeed.tech/tags/migrations.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [rails](<https://devfeed.tech/tags/rails.md>), [types](<https://devfeed.tech/tags/types.md>)

### AI overview

To add a money value to a Rails table that already stores integers and floats, the author uses a decimal column to avoid the rounding concerns of storing money as a float. The Rails 6.0 migration adds `decimal_val` to `metrics` with precision 8 and scale 2, placing it after `float_val`. The example says this format can hold values up to 999,999.99.

### Source excerpt

Like so many other things this falls into the category of "I'll do it 100 more times before I die and I can never remember it so may as well blog it". A migration adds a column to a table in a database managed by Rails. In this case I had a table which needed to manage multiple types of data all front ended by an amount method that dynamically figures out why field to fetch back the data from. This gave me a column structure like this: int_val (for integers) float_val (for floats like a measurement) And I needed to add money as a value to this table. Now, yes, I could simply store money in the float_val field but that's a bad practice to start doing because, well, rounding. Even if it really doesn't matter in the app, it is a bad practice to train yourself on. From having done this in the past, I know I need a decimal of the format (something, 2). This is referred to as the 'scale' and the 'precision' (the number of digits to the right of the decimal place). So if we have decimal(8,2), that means you can store: 123,456.78 So your maximum value would be 999,999.99 (just under a million dollars; now say that in a Dr. Evil intonation). Now writing a migration with precision and scale isn't hard but I always want to do this to allow for placing the column in the right place (it makes my tables 'near' and, yes, I'm just that nerdy). Here's my migration: bundle exec rails g migration add_decimal_to_metrics invoke active_record create db/migrate/20191118100314_add_decimal_to_metrics.rb class AddDecimalToMetrics < ActiveRecord::Migration[6.0] def change add_column :metrics, :decimal_val, :decimal, precision: 8, scale: 2, after: :float_val end end References Stack Overflow on Scale and Precision. Mitrev on Migrations