Python thập phân

Hàm thập phân trong Python. Hiệp 1

Cải thiện bài viết

Lưu bài viết

Thích bài viết

  • Độ khó. Dễ dàng
  • Cập nhật lần cuối. 22 tháng 1 năm 2022

  • Đọc
  • Bàn luận
  • khóa học
  • Luyện tập
  • Băng hình
  • Cải thiện bài viết

    Lưu bài viết

    Python theo định nghĩa của nó cung cấp một số phương thức nhất định để thực hiện phép tính số học dấu phẩy động thập phân nhanh hơn bằng cách sử dụng mô-đun “thập phân”.  
    Các phép toán quan trọng trên số thập phân
    1. sqrt[]. - Hàm này tính căn bậc hai của số thập phân
    2. kinh nghiệm[]. - Hàm này trả về e^x [số mũ] của số thập phân
     

    Python3




    # Python code to demonstrate the working of

    # sqrt[] and exp[]

     

    # importing "decimal" module to use decimal functions

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    0
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    1

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    2

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    3
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    7

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    8

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    9
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    6
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    3

     

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    4

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    7
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8_______0_______4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    2

     

    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    3

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    6
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8_______0_______4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The result of comparison using compare[] is : 1
    The result of comparison using compare_total_mag[] is : -1
    1

    đầu ra.  
     

    The exponent of decimal number is : 90.01713130052181355011545675
    The square root of decimal number is : 2.121320343559642573202533086

    3. ln[]. - Hàm này dùng để tính logarit tự nhiên của số thập phân
    4. log10[]. - Hàm này dùng để tính log [cơ số 10] của một số thập phân
     

    Python3




    # Python code to demonstrate the working of

    The result of comparison using compare[] is : 1
    The result of comparison using compare_total_mag[] is : -1
    3

     

    # importing "decimal" module to use decimal functions

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    0
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    1

     

    The result of comparison using compare[] is : 1
    The result of comparison using compare_total_mag[] is : -1
    7

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    3
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    6
    The absolute value using copy_abs[] is : 9.5600000000000004973799150320701301097869873046875
    The negated value using copy_negate[] is : 9.5600000000000004973799150320701301097869873046875
    The sign effected value using copy_sign[] is : -9.5299999999999993605115378159098327159881591796875
    2

     

    The absolute value using copy_abs[] is : 9.5600000000000004973799150320701301097869873046875
    The negated value using copy_negate[] is : 9.5600000000000004973799150320701301097869873046875
    The sign effected value using copy_sign[] is : -9.5299999999999993605115378159098327159881591796875
    3

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    9
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    6
    The absolute value using copy_abs[] is : 9.5600000000000004973799150320701301097869873046875
    The negated value using copy_negate[] is : 9.5600000000000004973799150320701301097869873046875
    The sign effected value using copy_sign[] is : -9.5299999999999993605115378159098327159881591796875
    8

     

    The absolute value using copy_abs[] is : 9.5600000000000004973799150320701301097869873046875
    The negated value using copy_negate[] is : 9.5600000000000004973799150320701301097869873046875
    The sign effected value using copy_sign[] is : -9.5299999999999993605115378159098327159881591796875
    9

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The minimum of two numbers is : 7.429999999999999715782905696
    The maximum of two numbers is : 9.529999999999999360511537816
    2
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    2

     

    The minimum of two numbers is : 7.429999999999999715782905696
    The maximum of two numbers is : 9.529999999999999360511537816
    8

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6# Python code to demonstrate the working of1
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The result of comparison using compare[] is : 1
    The result of comparison using compare_total_mag[] is : -1
    1

    đầu ra.  
     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118

    5. as_tuple[]. - Trả về số thập phân dưới dạng bộ chứa 3 đối số, dấu [0 cho +, 1 cho -], chữ số và giá trị số mũ
    6. fma[a,b]. - “fma” này là viết tắt của fused multiple và add. Nó tính toán [num*a]+b từ các số trong đối số. Không làm tròn số [num*a] trong hàm này
    Ví dụ.  
     

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13

     

    Python3




    # Python code to demonstrate the working of

    # Python code to demonstrate the working of8

     

    # importing "decimal" module to use decimal functions

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    0
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    1

     

    # sqrt[] and exp[]2

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    3
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5# sqrt[] and exp[]6_______0_______6# sqrt[] and exp[]8

     

    # sqrt[] and exp[]9

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    9
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5# importing "decimal" module to use decimal functions3_______205_______4# importing "decimal" module to use decimal functions5# importing "decimal" module to use decimal functions6# importing "decimal" module to use decimal functions7# importing "decimal" module to use decimal functions8

     

    # importing "decimal" module to use decimal functions9

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    02
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8_______0_______4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    2

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    08

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    11
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The result of comparison using compare[] is : 1
    The result of comparison using compare_total_mag[] is : -1
    1

    đầu ra.  
     

    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13

    7. so sánh[]. - Hàm này dùng để so sánh các số thập phân. Trả về 1 nếu đối số thập phân thứ nhất lớn hơn đối số thứ 2, -1 nếu đối số thập phân thứ nhất nhỏ hơn đối số thứ 2 và 0 nếu cả hai bằng nhau
    8. so_total_mag[]. - So sánh tổng độ lớn của các số thập phân. Trả về 1 nếu đối số thập phân thứ nhất lớn hơn đối số thứ 2 [bỏ qua dấu], -1 nếu đối số thập phân thứ nhất nhỏ hơn đối số thứ 2 [bỏ qua dấu] và 0 nếu cả hai bằng nhau [bỏ qua dấu]
     

    Python3




    # Python code to demonstrate the working of

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    18

     

    # importing "decimal" module to use decimal functions

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    0
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    1

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    22

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    3
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    26# importing "decimal" module to use decimal functions8

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    22

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    9
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5# sqrt[] and exp[]6_______0_______33# importing "decimal" module to use decimal functions8

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    35

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    38
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    43

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    44

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    47
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    52

    đầu ra.  
     

    The result of comparison using compare[] is : 1
    The result of comparison using compare_total_mag[] is : -1

    9. copy_abs[]. - Hàm này in giá trị tuyệt đối của đối số thập phân
    10. copy_negate[]. - Hàm này in phủ định của đối số thập phân
    11. copy_sign[]. - Hàm này in đối số đầu tiên bằng cách sao chép dấu từ đối số thứ 2
     

    Python3




    # Python code to demonstrate the working of

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    54

     

    # importing "decimal" module to use decimal functions

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    0
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    1

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    22

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    3
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    26# importing "decimal" module to use decimal functions8

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    22

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    9
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5# sqrt[] and exp[]6_______0_______33# importing "decimal" module to use decimal functions8

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    71

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    74
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    79

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    80

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    83
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    88

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    89

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    92
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8_______0_______4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    97

    đầu ra.  
     

    The absolute value using copy_abs[] is : 9.5600000000000004973799150320701301097869873046875
    The negated value using copy_negate[] is : 9.5600000000000004973799150320701301097869873046875
    The sign effected value using copy_sign[] is : -9.5299999999999993605115378159098327159881591796875

    12. tối đa[]. - Hàm này tính tổng hai số thập phân lớn nhất
    13. phút[]. - Hàm này tính tổng nhỏ nhất của hai số thập phân
     

    Python3




    # Python code to demonstrate the working of

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    99

     

    # importing "decimal" module to use decimal functions

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    0
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    1

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    22

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    3
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    26# importing "decimal" module to use decimal functions8

     

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    22

    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    9
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    13# importing "decimal" module to use decimal functions8

     

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    15

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    18
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    23
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    24
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    25

     

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    26

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    6
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    29
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    8
    The natural logarithm of decimal number is : 1.504077396776274073373258352
    The log[base 10] of decimal number is : 0.6532125137753436793763169118
    4
    The tuple form of decimal number is : DecimalTuple[sign=1, digits=[4, 5], exponent=-1]
    The fused multiply and addition of decimal number is : 13
    0

    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    5
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    23
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    35
    decimal.Decimal[5].fma[2,3] --> [5*2]+3 = 13
    25

    đầu ra.  
     

    The minimum of two numbers is : 7.429999999999999715782905696
    The maximum of two numbers is : 9.529999999999999360511537816

     

    Bài viết này được đóng góp bởi Manjeet Singh. Nếu bạn thích GeeksforGeeks và muốn đóng góp, bạn cũng có thể viết một bài báo bằng cách sử dụng write. chuyên viên máy tính. org hoặc gửi bài viết của bạn tới review-team@geeksforgeeks. tổ chức. Xem bài viết của bạn xuất hiện trên trang chính của GeeksforGeeks và trợ giúp các Geeks khác
     

     

    Vui lòng viết bình luận nếu bạn thấy bất cứ điều gì không chính xác hoặc bạn muốn chia sẻ thêm thông tin về chủ đề thảo luận ở trên
     


    Ghi chú cá nhân của tôi arrow_drop_up

    Cứu

    Vui lòng Đăng nhập để nhận xét.

    thập phân [] trong Python là gì?

    Trong Python, có một mô-đun tên là Decimal, được sử dụng để thực hiện một số tác vụ liên quan đến dấu phẩy động thập phân . Mô-đun này cung cấp số học dấu phẩy động được làm tròn chính xác. Để sử dụng nó, trước tiên chúng ta cần nhập mô-đun thư viện chuẩn Decimal. nhập số thập phân.

    Tại sao 0. 1 0. 2 không phải là 0. 3 con trăn?

    Tương tự, giá trị nhị phân của 0. 2 được lưu dưới dạng 0. 001100110. Bây giờ, khi bạn thêm 0. 1 + 0. 2 bằng Python [hoặc bằng một số ngôn ngữ lập trình khác], Python chuyển đổi 0. 1 và 0. 2 về dạng nhị phân. Sau đó, nó thực hiện phép cộng. Kết quả sẽ không bao giờ bằng 0. 3 chính xác .

    Chủ Đề