Jul-09-2019, 04:12 AM
inspired by my own post over here i coded this solution:
#!/usr/bin/env python3 from sys import argv def mininc(a): """Return the minimum float value that can increment the given value, and its power of 2""" v=float(a) u=1.0 p=0 r=u,p if v+u>v: while v+u>v: r=u,p u=u/2.0 if u==0: break p=p-1 elif v+u<v: raise ValueError('adding {} to {} goes down to {}'.format(repr(u),repr(v),repr(v+u))) else: while v+u==u: r=u,p u=u+u p=p+1 return r a=float(eval(argv[1])) b,p=mininc(a) print('the smallest value that makes a change when added to {} is {} (which is 2.0**{}) and then is {}'.format(repr(a),repr(b),repr(p),repr(a+b)))
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.