python Programming Glossary: decimal
In-memory size of python stucture http://stackoverflow.com/questions/1331471/in-memory-size-of-python-stucture also' 48 You could take this approach import sys import decimal d ... int 0 ... float 0.0 ... dict dict ... set set ... tuple.. tuple tuple ... list list ... str a ... unicode u a ... decimal decimal.Decimal 0 ... object object ... for k v in sorted d.iteritems.. tuple ... list list ... str a ... unicode u a ... decimal decimal.Decimal 0 ... object object ... for k v in sorted d.iteritems..
Format floats with standard json module http://stackoverflow.com/questions/1447287/format-floats-with-standard-json-module ' I want the floats to be formated with only two decimal digits. The output should look like this json.dumps 23.67 23.97..
Why do simple math operations on floating point return unexpected (inacurate) results in VB.Net and Python? http://stackoverflow.com/questions/1594985/why-do-simple-math-operations-on-floating-point-return-unexpected-inacurate-re
Convert hex string to int in Python http://stackoverflow.com/questions/209513/convert-hex-string-to-int-in-python 16 With the 0x prefix Python can distinguish hex and decimal automatically print int 0xdeadbeef 0 3735928559 print int 10..
Decimal place issues with floats and decimal.Decimal http://stackoverflow.com/questions/286061/decimal-place-issues-with-floats-and-decimal-decimal place issues with floats and decimal.Decimal I seem to be losing a lot of precision with floats... eqn However the answers I get back aren't precise to the decimal place. For example upon rearranging the second equation from.. powers i.e Decimal x 2 . Any ideas python floating point decimal floating accuracy share improve this question I'm not familiar..
Weighted random selection with and without replacement http://stackoverflow.com/questions/352670/weighted-random-selection-with-and-without-replacement 1 and thus partition 2. If the partition is split use the decimal portion of the shifted random number to decide the split. In..
Floating Point Limitations http://stackoverflow.com/questions/406361/floating-point-limitations behind this inaccuracy . If you need to keep the exact decimal representation you should use the decimal module . share improve..
python limiting floats to two decimal points http://stackoverflow.com/questions/455612/python-limiting-floats-to-two-decimal-points limiting floats to two decimal points I want a to be rounded to 13.95 a 13.949999999999999.. round a 2 13.949999999999999 If you are after only two decimal places as in currency then you have a couple of better choices..
Python code to pick out all possible combinations from a list? http://stackoverflow.com/questions/464864/python-code-to-pick-out-all-possible-combinations-from-a-list thing that occurs to me would be to just loop through the decimal integers 1 32768 and convert those to binary and use the binary..
Python decimal range() step value http://stackoverflow.com/questions/477486/python-decimal-range-step-value decimal range step value Is there a way to step between 0 and 1 by..
Convert XML/HTML Entities into Unicode String in Python http://stackoverflow.com/questions/57708/convert-xml-html-entities-into-unicode-string-in-python
drop trailing zeros from decimal http://stackoverflow.com/questions/11227620/drop-trailing-zeros-from-decimal trailing zeros from decimal I have a long list of Decimals and that I have to adjust by factors of 10 100 1000 ..... 1000000.. I want to get rid of. For example... from decimal import Decimal # outputs 25.0 PROBLEM I would like it to output 25 print Decimal.. # outputs 25.0 PROBLEM I would like it to output 25 print Decimal '2.5' 10 # outputs 2567.8000 PROBLEM I would like it to output..
Python float - str - float weirdness http://stackoverflow.com/questions/1778368/python-float-str-float-weirdness
Python JSON serialize a Decimal object http://stackoverflow.com/questions/1960516/python-json-serialize-a-decimal-object JSON serialize a Decimal object I have a Decimal '3.9' as part of an object and wish.. JSON serialize a Decimal object I have a Decimal '3.9' as part of an object and wish to encode this to a JSON.. a good way to serialize this JSONDecoder doesn't accept Decimal objects and converting to a float beforehand yields 'x' 3.8999999999999999..
How to define a decimal class holding 1000 digits in python? http://stackoverflow.com/questions/19980840/how-to-define-a-decimal-class-holding-1000-digits-in-python This number using decimal.Decimal shows like this from decimal import Decimal as dc x dc 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113.. using decimal.Decimal shows like this from decimal import Decimal as dc x dc 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113.. x Decimal '3.141592653589793115997963468544185161590576171875' But I need..
How to Convert DD to DMS in Python http://stackoverflow.com/questions/2579535/how-to-convert-dd-to-dms-in-python to Convert DD to DMS in Python How Do you Convert Decimal Degrees to Degrees Minutes Secands In Python Is there a Formula..
Decimal place issues with floats and decimal.Decimal http://stackoverflow.com/questions/286061/decimal-place-issues-with-floats-and-decimal-decimal place issues with floats and decimal.Decimal I seem to be losing.. place issues with floats and decimal.Decimal I seem to be losing a lot of precision with floats. For example.. is quite large. Is there a way around this I tried the Decimal class but it does not work well with powers i.e Decimal x 2..
numpy array with dtype Decimal? http://stackoverflow.com/questions/7770870/numpy-array-with-dtype-decimal array with dtype Decimal Are Decimal dtypes available in numpy import decimal numpy.. array with dtype Decimal Are Decimal dtypes available in numpy import decimal numpy d decimal.Decimal.. dtypes available in numpy import decimal numpy d decimal.Decimal '1.1' s '123.123' '23' '2323.212' '123123.21312' ss numpy.array..
|