practicalli / practicalli/clojure

Mathematical precision - floats and big decimal

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
117
Forks
36
PR merge metrics
No merged PRs in 30d

Description

;; vinurs 01:19
;; how can i make
(+ 0.3 0.6)
;; equal to 0.9?
;; and
(+ 0.2 0.1)
;; equal => 0.30

;; quick answer is, use bigdecimal
(+ 0.3M 0.6M)

Most floating point numbers (Java type float and double, based on IEEE 754 standard) are approximations. This section of the Clojure equality guide article might have some useful info: https://clojure.org/guides/equality#_floating_point_numbers_are_usually_approximations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the issue examples and the linked Clojure equality guide section on floating-point approximations. Locate the relevant documentation section in this repository, then document why the arithmetic results differ and how BigDecimal literals address the examples shown. Done means the explanation and examples are clear and accurate.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.