Logo

Programming-Idioms

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

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
(def a 1234567890.12345678901M)
decimal a = 1234567890.12345678901m;
  integer, parameter :: qp = selected_real_kind(20)
  real(kind=qp) :: a
import "math/big"
a, _, err := big.ParseFloat("123456789.123456789123465789", 10, 200, big.ToZero)
import static java.math.RoundingMode.HALF_UP;
import java.math.BigDecimal;
import java.math.MathContext;
String pi = "3.14159265358979323846";
MathContext m = new MathContext(21, HALF_UP);
BigDecimal a = new BigDecimal(pi, m);
use bignum;
my $a = 12345678901234567890.1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
import decimal	
a = decimal.Decimal('1234567890.123456789012345')
require 'bigdecimal'
a = BigDecimal('1234567890.12345678901')
use rust_decimal::Decimal;
use std::str::FromStr;
let a = Decimal::from_str("1234567890.123456789012345").unwrap();