+ 1

in python what is this?how,what this cod did?

>>> a=123456789123456789123456789.123456789123456789 >>> print(a) 1.2345678912345679e+26

27th Apr 2017, 4:53 AM
pawan tripathi
pawan tripathi - avatar
6 ответов
+ 11
@Dinmukhamed is right
27th Apr 2017, 4:59 AM
Agus Mei
Agus Mei - avatar
+ 8
Changes to scientific notation of a number: e+26 means ×10^26
27th Apr 2017, 4:56 AM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 8
Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem: >>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) # Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) # Decimal('0.1428571428571428571428571429') source: https://docs.python.org/2/library/decimal.html https://docs.python.org/3/library/decimal.html
27th Apr 2017, 5:06 AM
visph
visph - avatar
+ 6
Floating point numbers are stored as: significand * base^exponent In short, this *always* is the best possible *approximation* of a given number. For some numbers, as long as they can be represented fully in the binary system, the approximation is 100%. But for majority of real numbers, there is a finite precision that the number can be represented. And scientific notation does just that - it tells you how good an approximation this is.
27th Apr 2017, 6:28 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
>>> a=33.5 >>> print(a) 33.5 then why it's not print all values(all no which before decimal point) of a .
27th Apr 2017, 5:05 AM
pawan tripathi
pawan tripathi - avatar
+ 1
1.2345678912345679e+26 it is a standard notation to represent large numbers. therefore the output is to be interpreted as 1.2345678912345679 x 10^26 also notice that there is loss of precision in the output or the answer is shortened ; I have no idea about that .
7th May 2017, 3:17 PM
Tushar Jain
Tushar Jain - avatar