private pure subroutine expand_exact(value, exact, n_exact, point_pos)
Exact decimal expansion of a finite, strictly positive value.
An IEEE value is mantissa * 2**pow2 with an integer mantissa. When
pow2 is negative that equals mantissa * 5**(-pow2) / 10**(-pow2),
so the exact decimal digits are the digits of the big integer
mantissa * 5**(-pow2) with the point shifted -pow2 places. When
pow2 is positive the value is the integer mantissa * 2**pow2.
Either way no rounding whatsoever happens here.
On return the value equals 0.<digits> * 10**point_pos, where
<digits> is exact(1:n_exact).
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Variables
Type
Visibility
Attributes
Name
Initial
integer(kind=int64),
private
::
limb(MAX_LIMBS)
integer(kind=int64),
private
::
mantissa
integer(kind=default_int),
private
::
n_bits
integer(kind=default_int),
private
::
n_limb
integer(kind=default_int),
private
::
pow2
integer(kind=default_int),
private
::
shift
Source Code
pure subroutine expand_exact(value,exact,n_exact,point_pos)!! Exact decimal expansion of a finite, strictly positive value.!!!! An IEEE value is `mantissa * 2**pow2` with an integer mantissa. When!! `pow2` is negative that equals `mantissa * 5**(-pow2) / 10**(-pow2)`,!! so the exact decimal digits are the digits of the big integer!! `mantissa * 5**(-pow2)` with the point shifted `-pow2` places. When!! `pow2` is positive the value is the integer `mantissa * 2**pow2`.!! Either way no rounding whatsoever happens here.!!!! On return the value equals `0.<digits> * 10**point_pos`, where!! `<digits>` is `exact(1:n_exact)`.real(dp),intent(in)::valuecharacter(len=*),intent(out)::exactinteger(default_int),intent(out)::n_exactinteger(default_int),intent(out)::point_posinteger(int64)::limb(MAX_LIMBS)integer(int64)::mantissainteger(default_int)::n_limb,n_bits,pow2,shiftn_bits=int(digits(value),default_int)pow2=int(exponent(value),default_int)-n_bitsmantissa=int(scale(fraction(value),n_bits),int64)call bd_set(limb,n_limb,mantissa)shift=0_default_intif(pow2>0_default_int)then call bd_mul_pow(limb,n_limb,2_int64,pow2)else if(pow2<0_default_int)then call bd_mul_pow(limb,n_limb,5_int64,-pow2)shift=-pow2end if call bd_to_digits(limb,n_limb,exact,n_exact)point_pos=n_exact-shiftend subroutine expand_exact