Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Update floats.md #85

Open
wants to merge 2 commits into
base: apopiak-floats
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions current/runtime/floats.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ lang: en
title: Floating Point Numbers
---

When developing for the Substrate runtime and doing calculations it is appealing to use floating point numbers for e.g. representing fractions. This document covers why traditional floating point numbers are problematic in a runtime context and what alternatives exist.
When developing for the Substrate runtime and doing calculations it is appealing to use floating point numbers for e.g. representing fractions. In Substrate it is important that each node arrives at the same deterministic result for consensus. This document covers why traditional floating point numbers are problematic in runtime and what alternatives exist.

## Problems with Floating Point Numbers in the Runtime
## Problems with Floating Point Numbers in Runtime
wheresaddie marked this conversation as resolved.
Show resolved Hide resolved

The standard way of handling floating points is dependent on the need for decimal places by using one of the in-built primitive types of handlingfix point arithmetic. Floating point numbers are not deterministic and fixed point computation is safe for Substrate since it represents all rationals as a fraction thus resolving a deterministic result. The two types which are used to handle large fixed point arithmetic are Permill and Perbill, you can refer to [safe math](https://substrate.dev/recipes/3-entrees/safemath.html)for further information and implementation.
wheresaddie marked this conversation as resolved.
Show resolved Hide resolved

## Alternatives

Expand Down