Example #1
0
def test_Float():
    # NOTE prec is the whole number of decimal digits
    assert str(Float('1.23', prec=1+2))    == '1.23'
    assert str(Float('1.23456789', prec=1+8))  == '1.23456789'
    assert str(Float('1.234567890123456789', prec=1+18))    == '1.234567890123456789'
    assert str(pi.evalf(1+2))   == '3.14'
    assert str(pi.evalf(1+14))  == '3.14159265358979'
    assert str(pi.evalf(1+64))  == '3.1415926535897932384626433832795028841971693993751058209749445923'
    assert str(pi.round(-1)) == '0.'
    assert str((pi**400 - (pi**400).round(1)).n(2)) == '-0.e+88'
Example #2
0
def test_Float():
    # NOTE prec is the whole number of decimal digits
    assert str(Float("1.23", prec=1 + 2)) == "1.23"
    assert str(Float("1.23456789", prec=1 + 8)) == "1.23456789"
    assert str(Float("1.234567890123456789", prec=1 + 18)) == "1.234567890123456789"
    assert str(pi.evalf(1 + 2)) == "3.14"
    assert str(pi.evalf(1 + 14)) == "3.14159265358979"
    assert str(pi.evalf(1 + 64)) == "3.1415926535897932384626433832795028841971693993751058209749445923"
    assert str(pi.round(-1)) == "0."
    assert str((pi ** 400 - (pi ** 400).round(1)).n(1)) == "-0.e+91"
Example #3
0
def test_Float():
    # NOTE prec is the whole number of decimal digits
    assert str(Float('1.23', prec=1 + 2)) == '1.23'
    assert str(Float('1.23456789', prec=1 + 8)) == '1.23456789'
    assert str(Float('1.234567890123456789',
                     prec=1 + 18)) == '1.234567890123456789'
    assert str(pi.evalf(1 + 2)) == '3.14'
    assert str(pi.evalf(1 + 14)) == '3.14159265358979'
    assert str(pi.evalf(1 + 64)) == ('3.141592653589793238462643383279'
                                     '5028841971693993751058209749445923')
    assert str(pi.round(-1)) == '0.'
    assert str((pi**400 - (pi**400).round(1)).n(2)) == '-0.e+88'
Example #4
0
def test_Float():
    # NOTE dps is the whole number of decimal digits
    assert str(Float('1.23', dps=1 + 2)) == '1.23'
    assert str(Float('1.23456789', dps=1 + 8)) == '1.23456789'
    assert str(
        Float('1.234567890123456789', dps=1 + 18)) == '1.234567890123456789'
    assert str(pi.evalf(1 + 2)) == '3.14'
    assert str(pi.evalf(1 + 14)) == '3.14159265358979'
    assert str(pi.evalf(1 + 64)) == ('3.141592653589793238462643383279'
                                     '5028841971693993751058209749445923')
    assert str(pi.round(-1)) == '0.'
    assert str((pi**400 - (pi**400).round(1)).n(2)) == '-0.e+88'
    assert str(Float(S.Infinity)) == 'inf'
    assert str(Float(S.NegativeInfinity)) == '-inf'
Example #5
0
def test_Float():
    # NOTE dps is the whole number of decimal digits
    assert str(Float('1.23', dps=1 + 2)) == '1.23'
    assert str(Float('1.23456789', dps=1 + 8)) == '1.23456789'
    assert str(
        Float('1.234567890123456789', dps=1 + 18)) == '1.234567890123456789'
    assert str(pi.evalf(1 + 2)) == '3.14'
    assert str(pi.evalf(1 + 14)) == '3.14159265358979'
    assert str(pi.evalf(1 + 64)) == ('3.141592653589793238462643383279'
                                     '5028841971693993751058209749445923')
    assert str(pi.round(-1)) == '0.0'
    assert str((pi**400 - (pi**400).round(1)).n(2)) == '-0.e+88'
    assert sstr(Float("100"), full_prec=False, min=-2, max=2) == '1.0e+2'
    assert sstr(Float("100"), full_prec=False, min=-2, max=3) == '100.0'
    assert sstr(Float("0.1"), full_prec=False, min=-2, max=3) == '0.1'
    assert sstr(Float("0.099"), min=-2, max=3) == '9.90000000000000e-2'
Example #6
0
def test_Float():
    # NOTE dps is the whole number of decimal digits
    assert str(Float("1.23", dps=1 + 2)) == "1.23"
    assert str(Float("1.23456789", dps=1 + 8)) == "1.23456789"
    assert str(Float("1.234567890123456789",
                     dps=1 + 18)) == "1.234567890123456789"
    assert str(pi.evalf(1 + 2)) == "3.14"
    assert str(pi.evalf(1 + 14)) == "3.14159265358979"
    assert str(pi.evalf(1 + 64)) == ("3.141592653589793238462643383279"
                                     "5028841971693993751058209749445923")
    assert str(pi.round(-1)) == "0.0"
    assert str((pi**400 - (pi**400).round(1)).n(2)) == "-0.e+88"
    assert sstr(Float("100"), full_prec=False, min=-2, max=2) == "1.0e+2"
    assert sstr(Float("100"), full_prec=False, min=-2, max=3) == "100.0"
    assert sstr(Float("0.1"), full_prec=False, min=-2, max=3) == "0.1"
    assert sstr(Float("0.099"), min=-2, max=3) == "9.90000000000000e-2"