Representation error refers to fact that some (most, actually) decimal fractions cannot be represented exactly as binary (base 2) fractions. This is the chief reason why Python (or Perl, C, C++, Java, Fortran, and many others) often won’t display the exact decimal number you expect:
>>> 0.1
0.10000000000000001Why is that? 1/10 is not exactly representable as a binary fraction. Almost all machines today use floating point arithmetic, and almost all platforms map Python floats to “double precision”. doubles contain 53 bits of precision, so on input the computer strives to convert 0.1 to the closest fraction it can of the form J/2**N where J is an integer containing exactly 53 bits. Rewriting
1 / 10 ~= J / (2**N)as J ~= 2**N / 10 and recalling that J has exactly 53 bits (is >= 2**52 but < 2**53), the best value for N is 56: >>> 2**524503599627370496L>>> 2**539007199254740992L>>> 2**56/107205759403792793L That is, 56 is the only value for N that leaves J with exactly 53 bits. The best possible value for J is then that quotient rounded: >>> q, r = divmod(2**56, 10)>>> r6L Since the remainder is more than half of 10, the best approximation is obtained by rounding up: >>> q+17205759403792794L Therefore the best possible approximation to 1/10 in double precision is that over 2**56, or 7205759403792794 / 72057594037927936. Note that since we rounded up, this is actually a little bit larger than 1/10; if we had not rounded up, the quotient would have been a little bit smaller than 1/10. But in no case can it be exactly 1/10! So the computer never “sees” 1/10: what it sees is the exact fraction given above, the best double approximation it can get: >>> .1 * 2**567205759403792794.0 .If we multiply that fraction by 10**30, we can see the (truncated) value of its 30 most significant decimal digits: >>> 7205759403792794 * 10**30 / 2**56100000000000000005551115123125L meaning that the exact number stored in the computer is approximately equal to the decimal value 0.100000000000000005551115123125. Rounding that to 17 significant digits gives the 0.10000000000000001 that Python displays (well, will display on any conforming platform that does best-possible input and output conversions in its C library
Posted in Technology | 1 Comment »
I regret for having a wrong opinion for this man over a long period. Any leader who is not in sync with the law of the state is more accountable to the people rather than a mainstream siyase debauch. Separatists sell name of the people to the supporing(funding agencies). When other chors/ renegades(Moulvi Farooq, Yaseen Malik, Bilal Lone, Shabir Shah and hell lot of others) are preparing to sell precious lives of kashmiris for their own long term political mileage, there is still one man who is not compromising with his consciousness i.e Mr. Geelani. I hold this person in highest esteem for his sheer determination and grit to fight for the cause which is so dear to me.
Posted in Politics | Leave a Comment »
Every company faces the problem of people leaving the company for better pay or profile.
The answer lies in one of the largest studies undertaken by the Gallup Organization. The study surveyed over a million employees and 80,000 managers and was published in a book called “First Break All the Rules”. It came up with this surprising finding:
If you’re losing good people, look to their immediate boss. Immediate boss is the reason people stay and thrive in an organization. And he’s the reason why people leave. When people leave they take knowledge, experience and contacts with them, straight to the competition.
“People leave managers not companies”
Mostly manager drives people away?
HR experts say that of all the abuses, employees find humiliation the most intolerable. The first time, an employee may not leave, but a thought has been planted. The second time, that thought gets strengthened. The third time, he looks for another job.
When people cannot retort openly in anger, they do so by passive aggression. By digging their heels in and slowing down. By doing only what they are told to do and no more. By omitting to give the boss crucial information. “If you work for a jerk, you basically want to get him into trouble. You don’t have your heart and soul in the job.“
Different managers can stress out employees in different ways – by being too controlling, too suspicious, too pushy, too critical, but they forget that workers are not fixed assets, they are free agents. When this goes on too long, an employee will quit – often over a trivial issue.
Talented men leave. Dead wood doesn’t.
“Jack Welch of GE once said. A company’s value lies “between the ears of its employees”.
Posted in Society | 1 Comment »
If you are not comfortable with
AJAX, here is an alternative. The idea is you use
IE inter page transitions. Put these tags in the head of your html document.
<META http-equiv="Page-Enter" content="blendTrans(Duration=0.2)">
<META http-equiv="Page-Exit" content="blendTrans(Duration=0.2)">
Essentially what IE does is capture an image of the page before, and then
Renders the new page in memory first to create a second image. It then uses DirectX to smoothly
Blend one image to another.
This simple trick alone gives you about 50% of the benefit of
ajax,with a 1% of the effort.
To get the full benefits of ajax,you will of course need to use
ajax
Posted in Technology | Leave a Comment »
I have not been blogging for the last 2 months and i will not do so for the next 2 weeks.
Posted in Uncategorized | Leave a Comment »
Musharraf says “In the line of fire” that there is a power that works above government in both india and pakistan. I agree with this because the judicary in one of the biggest democracies works under the perview of that force especially when extending sentences to kashmiri’s. Everything that happens in kashmir is controlled and coordinated by this force. This is the force which kills innocents, This is the force which creates sex scandals, This is the force which hangs kashmiri people. Let’s fight against this force and its accomplices.
Posted in Politics | 1 Comment »
Pluto has been classified as a dwarf planet now. Any celestial body that adhers to one of the following properties is treated as a dwarf planet:
1. Is in orbit around the sun 2. Has sufficient mass to assume a hydrostatic equilibrium.
3. Is not a sattelite of a plante 4. Has not ‘cleared the neighbourhood’
This definition reclassified pluto from a planet to a dwarf planet because it has not cleared the neighbourhood of its orbit.
Posted in Science | 2 Comments »
A ‘platform always beats an application’ myth has been made irrelevant by open source community. In each of its past confrontations with rivals, Microsoft has successfully played the platform card, trumping even the most dominant applications. Windows allowed Microsoft to displace Lotus 1-2-3 with Excel, WordPerfect with Word, and Netscape Navigator with Internet Explorer.
This time, though, the clash isn’t between a platform and an application, but between two platforms, each with a radically different business model: On the one side, a single software provider, whose massive installed base and tightly integrated operating system and APIs give control over the programming paradigm; on the other, a system without an owner, tied together by a set of protocols, open standards and agreements for cooperation.
Posted in Technology | Leave a Comment »