Posts Tagged ‘Javascript’

March 5, 2012

Javascript: The Good Parts by Douglas Crockford

Advertisements

!0 is 1

September 27, 2010

!0 === 1

Only tested this in Javascript and Ruby, but I bet it works in C like it did in Javascript.

mars@scheherazade:~$ js
Rhino 1.7 release 2 2010 01 20

js> 3+!0
4

Ruby is safeguarded against such hijinks:

mars@scheherazade:~$ irb
irb(main):001:0> 3+!0
TypeError: false can't be coerced into Fixnumfrom (irb):1:in `+'from (irb):1from :0

flops

August 30, 2010

At least in Javascript, that’s how it works.  Apparently floating-point operations are not exactly accurate in a computer, the way integer arithmetic or arbitrary-precision arithmetic is.

Javascript

scheherazade:~$ js
Rhino 1.7 release 2 2010 01 20
js> .1+.2
0.30000000000000004

Berkeley Calculator

scheherazade:~$ 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.
.0003^2 + .0004^2 - .0005^2
0

(from the 3,4,5 right triangle used in the SAT)

August 11, 2010

Best Introduction to Javascript

August 11, 2010

Best Introduction to AJAX