Archives for the month of: July, 2012

• Integer is signed.so for n bits it stores 2^n-1 -1 to -2^n-1
• Unsigned can be used so that we can store from 0 to 2^n – 1.
• Thus for 16bits we have -32768 to 32767
• Typedef is like giving new names for int etc.
• Enum makes new types which can have fixed values given in braces eg. Enum day {mon,tue…..}
Here day can store any mon tue etc

• In storage normal use is auto
• Register makes variable local and saves in a register (you cannot lookup address of a register variable)
• Static makes it available even after control is transferred to the calling function
• Extern makes it available to all the functions of the file

• In making constants use define
• No use of ; ,all constants must be capital, no symbols except _
• And no =………eg #define MAX 20

• Declaring a value as const makes it unchangeable
• Volatile makes it changeable by external sources
• Using both it can be only changed externally

• Sizeof() is a operator and not a function

• In printing numbers %wd is used where w specifies field width. And numbers are filled from left and if %-wd then from right.

• In using float %w.pf is used where w is same and p denotes the no. of no.s after decimal

• In strings %w.ps is used where p denotes that only first p characters are to be printed.

• In a multi-dimensional array the elements are stored in a line in memory and can be accessed using pointers . a[i][j]=*(&a[0][0]+i*m+j)

• A structure is used to make use of something similar to objects

• In a structure a pointer can be used to refer to individual elements using ptr->elem.
• In union though declaration is similar to structure but memory is assigned of the size of the largest unit declared. And a union can have the value of only one type at a time.

Advertisements

Sharding for real?? (Week 7).

This post is just one among the various rants available online that use a bad-mouth for PHP despite the fact that it is successfully used in various sites such as Facebook, wikipedias, etc

So here’s what got me thinking working on my GSoC project on SemanticMediaWiki (an extension for MediaWiki), I mistakenly deleted some text from a .php file which was a public variable of a class. I tested and found that things are working fine and committed my patch when looking at the diff I was amazed how things were working. Then I ran some tests

<?php
class hello{

	public function __construct($name){
		$this->name = $name;
	}
}

$wy = new hello('sdfs');
echo $wy->name;

to my amazement this worked perfectly even though I hadn’t initialized $name earlier. This definitely prevents some bugs, but then I prefer bugs than unmanageable code.

GSoC midterm.

Claiming to be “SOCIAL” we humans continually try to do things to prove that we are in fact social beings, but ARE WE?

Long time back, we settled into civilizations all across the globe, we even tried to populate the moon and the Mars, we grew larger and larger in numbers started to build stuff, discover things, imagine things and what not. With this approach we kept on doing things thinking only of the near future (ofc we cannot think beyond that). While doing this we cut off lots of trees and forests and never cared about them.

Suddenly, we see now everyone is worried about the Global Warming, Extinction of Species and other issues that we try to address now. We tend to move to renewable sources of energy to minimize our impact on the world, become Vegans, not use leather products, etc. When asked “why?” we say “because we are social and we believe all living beings have equal shares on the earth”, REALLY??

The Ugly Truth is that we are concerned of our own future and nobody else’s. We only try to look social to hide from our inner self, but the bottom-line is we are GREEDY

P.S. I don’t know why I am writing this, probably I am fussed enough by the useless acts of people who state we are social