long-integer

How do I convert numbers with e to digits only?

How do I convert numbers with e to digits only? Question: I want to convert numbers like 1.28e+21 to a long digits only number but the following code doesn’t make a difference. n = 1.28e+21 b = 1.28*10**21 print(b) b still has an e. How do I get rid of e? Asked By: diviserbyzero || …

Total answers: 2

Python effective integer size

Python effective integer size Question: For example in C#, C++, Java or JavaScript effective int size is 32 bits. If we want to calculate some large number, for example, 70 bits, we should use some software features (Arbitrary-precision arithmetic). Python has a very tricky integer internal boundless representation and I’m can not figure out what …

Total answers: 3

"OverflowError: Python int too large to convert to C long" on windows but not mac

"OverflowError: Python int too large to convert to C long" on windows but not mac Question: I am running the exact same code on both windows and mac, with python 3.5 64 bit. On windows, it looks like this: >>> import numpy as np >>> preds = np.zeros((1, 3), dtype=int) >>> p = [6802256107, 5017549029, …

Total answers: 4

Using the sqrt function of math module for long numbers in python

Using the sqrt function of math module for long numbers in python Question: I was working with numbers of 200 digits in python. When finding the square root of a number using math.sqrt(n) I am getting a wrong answer. In[1]: n=9999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999998292000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000726067 In[2]: x=int(math.sqrt(n)) In[3]: x Out[1]: 10000000000000000159028911097599180468360808563945281389781327 557747838772170381060813469985856815104L In[4]: x*x Out[2]: 1000000000000000031805782219519836346574107361670094060730052612580 0264077231077619856175974095677538298443892851483731336069235827852 …

Total answers: 4

Python 'long' object has no attribute 'to_bytes'?

Python 'long' object has no attribute 'to_bytes'? Question: I’m trying to use a bitcoin address validator written in Python from here: This snippet gives me trouble though: def decode_base58(bc, length): n = 0 for char in bc: n = n * 58 + digits58.index(char) return n.to_bytes(length, ‘big’) I understand that n is either an int …

Total answers: 4

Why does built-in sum behave wrongly after "from numpy import *"?

Why does built-in sum behave wrongly after "from numpy import *"? Question: I have some code like: import math, csv, sys, re, time, datetime, pickle, os, gzip from numpy import * x = [1, 2, 3, … ] y = sum(x) The sum of the actual values in x is 2165496761, which is larger than …

Total answers: 3

Convert python long/int to fixed size byte array

Convert python long/int to fixed size byte array Question: I’m trying to implement RC4 and DH key exchange in python. Problem is that I have no idea about how to convert the python long/int from the key exchange to the byte array I need for the RC4 implementation. Is there a simple way to convert …

Total answers: 10