Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go

Idiom #192 Declare a real variable with at least 20 digits

Declare a real variable a with at least 20 digits; if the type does not exist, issue an error at compile time.

import "math/big"
a, _, err := big.ParseFloat("123456789.123456789123465789", 10, 200, big.ToZero)

2nd arg is the base.
3rd arg is the precision.
4th arg is the rounding mode.
The precision is the maximum number of mantissa bits available to represent the value.
(def a 1234567890.12345678901M)

java.math.BigDecimal

New implementation...
< >
tkoenig