Need a good pocket calculator?
Wayne Madsen linked to Cory Doctorow's post on pi day, and I, like the fool I am, posted a bc session calculating pi to 1999 good digits. It goes like this:
$ bc -l
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
pi=a(1)*4; pi
3.14159265358979323844
scale=2000
pi=a(1)*4
pi
3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
45432664821339360726024914127372458700660631558817488152092096282925\
40917153643678925903600113305305488204665213841469519415116094330572\
70365759591953092186117381932611793105118548074462379962749567351885\
75272489122793818301194912983367336244065664308602139494639522473719\
07021798609437027705392171762931767523846748184676694051320005681271\
45263560827785771342757789609173637178721468440901224953430146549585\
37105079227968925892354201995611212902196086403441815981362977477130\
99605187072113499999983729780499510597317328160963185950244594553469\
08302642522308253344685035261931188171010003137838752886587533208381\
42061717766914730359825349042875546873115956286388235378759375195778\
18577805321712268066130019278766111959092164201989380952572010654858\
63278865936153381827968230301952035301852968995773622599413891249721\
77528347913151557485724245415069595082953311686172785588907509838175\
46374649393192550604009277016711390098488240128583616035637076601047\
10181942955596198946767837449448255379774726847104047534646208046684\
25906949129331367702898915210475216205696602405803815019351125338243\
00355876402474964732639141992726042699227967823547816360093417216412\
19924586315030286182974555706749838505494588586926995690927210797509\
30295532116534498720275596023648066549911988183479775356636980742654\
25278625518184175746728909777727938000816470600161452491921732172147\
72350141441973568548161361157352552133475741849468438523323907394143\
33454776241686251898356948556209921922218427255025425688767179049460\
16534668049886272327917860857843838279679766814541009538837863609506\
80064225125205117392984896084128488626945604241965285022210661186306\
74427862203919494504712371378696095636437191728746776465757396241389\
086583264599581339047802759008
You don't have to store pi in an intermediate variable, of course.
Doctorow's blog had a lot of feedback, and some of that inspired me to calculate the pi moment:
scale = 31
pi = a(1) * 4
pi
3.1415926535897932384626433832792
date = (pi - 3) * 100
date
14.1592653589793238462643383279200
hour = (date - 14) * 24
hour
3.8223686155037723103441198700800
minute = (hour - 3) * 60
minute
49.3421169302263386206471922048000
second = (minnute - 49) * 60
second
-2940
second = (minute - 49) * 60
second
20.5270158135803172388315322880000
(Notice the woops with minnute, there. Also, notice that I have changed the evaluation between the date and the hour.)
March 14, 3:49:20.53 in the morning. FWIW.
bc allows defining functions, so you could write a general function that takes any decimal fraction and turn it into a moment.
Well, maybe not any. e, 2.7182818284590452353602874713526..., for instance.
There is, of course, no February 71st. Proof that it's easy to attempt to apply a system out of context. (I'm looking at you, Bill Gates. Take that abomination you call MS Office back off the market.)
Well, so bc is a pretty neat little calculator. (And so are Ruby and Python, among other full-blown languages.)
How do you get bc into your pocket?
Jailbreak your Android.
Don't try it on your iPhone, because you have to pay Apple something like a hundred dollars a year just to do things like this. And you have to have a stupid Intel processor Mac to do the development, last I heard. (I could almost forgive Intel the 8086 if they would just quit trying to kill the market for other processors and other companies, and if they would quit trying to take over the internet. Almost. That 8086 is never, ever, going to be power efficient, and we need power efficiency now. Intel, it's time to move over, get out of the way.)
Jailbreak your Android device, and if Android is too limiting, install Linux on it.
Saturday, March 17, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Courtesy is courteous.