34 lines
475 B
Python
34 lines
475 B
Python
|
#!/usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
|
||
|
def base10(x, b=2):
|
||
|
s = 0
|
||
|
k = len(x) - 1
|
||
|
for a in x:
|
||
|
s += int(a) * b ** k
|
||
|
k -= 1
|
||
|
return s
|
||
|
|
||
|
|
||
|
def base10Horner(x, b=2):
|
||
|
u = 0
|
||
|
for a in x:
|
||
|
u = b * u + int(a)
|
||
|
return u
|
||
|
|
||
|
|
||
|
def baseb(x, b):
|
||
|
s = ""
|
||
|
y = x
|
||
|
while y > 0:
|
||
|
s = str(y % b) + s
|
||
|
y //= b
|
||
|
return s
|
||
|
|
||
|
|
||
|
print(1 + 2**53)
|
||
|
print(1. + 2**53)
|
||
|
print((1. + 2.**53) - 2.**53)
|
||
|
print(1. + (2.**53 - 2.**53))
|