Thank you.
We aspire to be like you, but Steve Jobs will always be known as “The crazy one” and “The insanely awesome” visionary!
Your job is done, sleep well :)
And……a small gift for you: StayHungryStayFoolish.me
Utkarsh's mind.random() on Programming, India and Startups
Thank you.
We aspire to be like you, but Steve Jobs will always be known as “The crazy one” and “The insanely awesome” visionary!
Your job is done, sleep well :)
And……a small gift for you: StayHungryStayFoolish.me
I have always used Random’s nextInt() or nextLong(). So was curious on how “random” is it actually? Then I found this protected method next().
protected int next(int bits)
Implementation of Random.java via Google code:
1 2 3 4 5 6 7 8 9 | protected int next(int bits) { long oldseed, nextseed; AtomicLong seed = this.seed; do { oldseed = seed.get(); nextseed = (oldseed * multiplier + addend) & mask; } while (!seed.compareAndSet(oldseed, nextseed)); return (int)(nextseed >>> (48 - bits)); } |
The general contract of next is that it returns an int value and if the argument bits is between 1 and 32 (inclusive), then that many low-order bits of the returned value will be (approximately) independently chosen bit values, each of which is (approximately) equally likely to be 0 or 1. The method next is implemented by class Random by atomically updating the seed to
(seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1)and returning
(int)(seed >>> (48 - bits))This is a linear congruential pseudorandom number generator, as defined by D. H. Lehmer and described by Donald E. Knuth in The Art of Computer Programming, Volume 3: Seminumerical Algorithms, section 3.2.1.
Interesting!
EDIT: Something even more interesting: Why this code is giving strange result? So Random?
Link to JavaDocs for Random.
Just configured aquamacs and it’s awesome! Simple and quick. Will put up my .emacs and other details soon on github here.
Stuff I am using are:
1. ECB – emacs code browser
2. emacs-for-python which includes all the goodies you need for python development!
3. Solarized dark theme, whose emacs port is here.
My fav feature? It’s M-x artist-mode , see a screencast here
(HOW-TO: Use mouse middle button to get options, COMMAND+click on a mac. Exit using M-x artist-mode-off)
If you are using Aquamacs, I recommend you not to use ~/.emacs but directly edit the file which it loads, its located here: ~/Library/Preferences/Aquamacs Emacs/Preferences.el
The ultimate emacs course – An awesome 2hr video lecture for emacs!
Last week, me and 2 of my friends
decided to go to the university hackathon organized by eBay. It was fun! We built a python-django based web app called BuildMyPc, a vertical shopping app, something like SparkBuy, but built using eBay data.
Why? Because if you want to customize a desktop at home, there is nothing like buying cheap parts from eBay!
And our app was judged 2nd! The first prize went to an app built with some awesome javascript + eBay API hackery. Read the rest of this entry »
What is Area42?
1. Area: Taken from Area51, because its secret and very important/interesting people can be a part of it.
2. 42: We will share knowledge here. “The Answer to Life (tech), the Universe (tech) and Everything (tech)”.
3. Its uniqueness lies in less number of members == less noise.
4. All members have sudo rights!
Where is it?
Yeah right! It’s a secret!
Page optimized by WP Minify WordPress Plugin