Monday 17 October 2011

why there is a problem in NAN { Not a Number } with Java .

If you are new to java than it really helps you because there are somethings which generally looks like error and exceptions and they are . but do you ever think why this error or exception is coming in our program . 


Have you ever deal with NAN { not a number } :- you can say that this is a problem in java if you are "new to java" but if you are learning java from 3-4 months and now you are Java lover like me than you have to read pdf " JAVAHURTS " and when you complete this book after it you can easily say that NAN is created for performance and for user friendly .


generally "if else " is used by all programmer in this world . because i think "if else" is the basic thing for dividing the way . and when we use 


----------------------------
if( ----- )
{
}
else 
{
}
----------------------------


for all of us if is only this , but do you ever tried for which type of things are performed inside machine for implementing the " if else " loop . 


if-else in java performs too many things , there can be two type of things which are related with if-else loop .
so the dividing means comparision is done with some operator like 
 > , == , < , != , >= , =< .
so for me the comparision can be performed between two things or comparision can be performed between only one thing .


: - so there are two things 
-----------------------------------
if( one operand and one operator )
{
}
else
{
}
-----------------------------------
if( two operand and one operator )
{
}
else
{
}
-----------------------------------------------------------------


so different different things are performed between these two .
, lets start with " one operand and one operator "
so in it we have one value . and the comparision is peformed with 0 like


if(n == 0)//( n != 0) etc ...
{
}
else
{
}


so inside this type of code 


Conditional branch: Integer comparison with zero
OpcodeOperand(s)Description
ifeqbranchbyte1, branchbyte2pop int value, if value == 0, branch to offset
ifnebranchbyte1, branchbyte2pop int value, if value != 0, branch to offset
ifltbranchbyte1, branchbyte2pop int value, if value < 0, branch to offset
iflebranchbyte1, branchbyte2pop int value, if value <= 0, branch to offset
ifgtbranchbyte1, branchbyte2pop int value, if value > 0, branch to offset
ifgebranchbyte1, branchbyte2pop int value, if value >= 0, branch to offset



-----------------------------------------------------------------
lets start with " two operand and one operator "
here if-else is performed like


if( a > b ) // ( a == b ) etc ...
{
}
else
{
}




Conditional branch: Comparison of two integers
OpcodeOperand(s)Description
if_icmpeqbranchbyte1, branchbyte2pop int value2 and value1, if value1 == value2, branch to offset
if_icmpnebranchbyte1, branchbyte2pop int value2 and value1, if value1 != value2, branch to offset
if_icmpltbranchbyte1, branchbyte2pop int value2 and value1, if value1 < value2, branch to offset
if_icmplebranchbyte1, branchbyte2pop int value2 and value1, if value1 <= value2, branch to offset
if_icmpgtbranchbyte1, branchbyte2pop int value2 and value1, if value1 > value2, branch to offset
if_icmpgebranchbyte1, branchbyte2pop int value2 and value1, if value1 >= value2, branch to offset





now the topic " because we are cleared with all if-else conditions " 
so NAN in java is occurred  when we deal with floating point . now . perform a operation in if else 


 if (  Math.sqrt(-1) == Math.sqrt(-1) )
 {
 }
 else 
 {
 }


if you are new than you will say yes is the answer means if is followed . but why else is followed in this condition .
so the whole thing is lie in the floating point .


floating point comparision used 2 instruction which are *fcmpg* and *fcmpl* . so if you are doing operation or comparision between two simple float than they both will hold same value means result will occur when they hold same value , means both fcmpg and fcmpl instructions push a 0 if the values are equal, a 1 if the value1 is greater than value2, and a -1 if value1 is less than value2. But if one or both of the values is NaN, the fcmpg instruction pushes a 1, whereas the fcmpl instruction pushes a -1.


but we have a condition where the two instruction will hold different values when any instruction have NAN so thats the reason behind else is followed .
                                          thanks tushar .

Sunday 16 October 2011

difference between class and instance method initialization .

hello friends i find a topic which looks easy but the concept behind that topic is really beautiful . now how to start with this topic is really interesting for me , because i found some things which really looks different .

so lets start .

JAVA program is built with or created with 2 things . one is class fields , and second is object fields .
so generally we use those methods with the help of object and with the help of class name .
now my question is that how can you access things which are outside from the scope of the method .

just think about what i am saying .

How instance are initialized :-

now take a breath and start , when ever we use object with ( . ) operator at that time how can you access the method . so these type of questions comes in my mind and hurt me the most . but every time i will find a answer for my query .

when ever we create a object at that time we use "new" keyword , and the benefit of the new keyword is that all un-initialized methods are initialized by the new keyword means all methods and all rules ( interfaces ) and all variables are initialized by new keyword . so for initializing is performed in JVM . and this process is performed in constructor . but do you think how the bulky knows about constructor . thats the main thing . because this whole thing is performed in JVM with the machine level instruction and inside machine level and the constructor is known as <init> inside the machine ( JVM )  . so <init> is the instruction behind every instance level initialization and inside <init> this keyword performs its whole process .

How class methods are initialized :- 

now we all know that class methods and instance methods are totally different . but how the class method initialization can be different from instance initialization method . thats the main and pretty interesting thing .
now something will be real different thats why they perform different things in the real world of programming .
now inside every class method or inside every static method we have few instruction like invokestatic , putstatic , getstatic .when ever these types of instruction are found JVM executes <clinit> instruction inside this *cl-init* , "cl" stands for class initialization and whenever this instruction is performed or executed a pretty interesting thing is performed it is known as "the class or interface that declared the resolved field or method is
initialized if it has not been initialized already." from ( jvm specification ) . here resolve methods are those methods which are binded at compile time thats why they are known or called as resolve methods and in java
only static method are binded at compile time so static methods are resolved methods and initialized by <clinit> instruction .

now " we all say that static method can not access instance method directly " so the reason behind this is <clinit> cause .

                                                                                                                      thanks tushar .


how static and instance methods are initialized in JAVA .

hello friends i find a topic which looks easy but the concept behind that topic is really beautiful . now how to start with this topic is really interesting for me , because i found some things which really looks different .

so lets start .

JAVA program is built with or created with 2 things . one is class fields , and second is object fields .
so generally we use those methods with the help of object and with the help of class name .
now my question is that how can you access things which are outside from the scope of the method .

just think about what i am saying .

How instance are initialized :-

now take a breath and start , when ever we use object with ( . ) operator at that time how can you access the method . so these type of questions comes in my mind and hurt me the most . but every time i will find a answer for my query .

when ever we create a object at that time we use "new" keyword , and the benefit of the new keyword is that all un-initialized methods are initialized by the new keyword means all methods and all rules ( interfaces ) and all variables are initialized by new keyword . so for initializing is performed in JVM . and this process is performed in constructor . but do you think how the bulky knows about constructor . thats the main thing . because this whole thing is performed in JVM with the machine level instruction and inside machine level and the constructor is known as <init> inside the machine ( JVM )  . so <init> is the instruction behind every instance level initialization and inside <init> this keyword performs its whole process .

How class methods are initialized :- 

now we all know that class methods and instance methods are totally different . but how the class method initialization can be different from instance initialization method . thats the main and pretty interesting thing .
now something will be real different thats why they perform different things in the real world of programming .
now inside every class method or inside every static method we have few instruction like invokestatic , putstatic , getstatic .when ever these types of instruction are found JVM executes <clinit> instruction inside this *cl-init* , "cl" stands for class initialization and whenever this instruction is performed or executed a pretty interesting thing is performed it is known as "the class or interface that declared the resolved field or method is
initialized if it has not been initialized already." from ( jvm specification ) . here resolve methods are those methods which are binded at compile time thats why they are known or called as resolve methods and in java
only static method are binded at compile time so static methods are resolved methods and initialized by <clinit> instruction .

now " we all say that static method can not access instance method directly " so the reason behind this is <clinit> cause .

                                                                                                                      thanks tushar .


Wednesday 12 October 2011

IEEE-754 ... is the suitcase of errors but still used in JAVA why ...

Look every-thing is this world is created or built for some reason ... but my topic first part is indicating that IEEE-754 is the source of errors ... now what are the errors .
1 . can-not differentiate between -0.0 and + 0.0 in compile time .
2 . weak , complex number representation .
3 . what is NAN ... i think this should be represented with something else ... because if it is something than two   NAN should be equal .
4 . rounding off problem .

now i have represent 4 errors in front of you .. and still there are too many errors but still java follows IEEE-754
, now the question arises that still we are using the suitcase ...
now i will explain why we or JAVA is using IEEE-754 .
two examples ...
1 . rounding off .
2 . matrix problem .

Rounding off problem :- rounding off problem is created not by IEEE .. but we say that IEEE-754 is the source of rounding  off problem .
now who is the representator of this problem . if i say that our machine is the problem is the cause behind rounding off error ...
example :- create a application in your system ... where instruction set is for 64bit because ultimately every thing is stored in memory so JVM 32 bits consideration is wrong thinking .

           and perform 4/7 : -and your machine will get the answer ( .5714285714285714)
but if your machine or windows console represent only 4 bits than you will get -- ( .5714 )
and if 6 bits supported by windows console than you will get -- ( .571428 )
if you will use 7 bits than you will get ( .57144286 )

see all results we get are different means we are depend upon machine representation .. now why we use IEEE-754 . we use it because when c is created after it we have nothing for proper understanding of floating point representation so in 1985 IEEE-754 is created and C just use it , because it is feasible and lighter for programmer who need speed now what is the relation to speed now i will explain it in matrix multiplication .

Matrix problem :- matrix problem is the ... very typical problem now how it is typical ...
********************** C = A.B ************************
perform this operation ..
look we have two options ...
1 . accurate result .
2 . speed .

if you love accurate result than IEEE-754 hurts you because when you multiply this matrix and solve the terms in matrix than we have to perform addition there which are all in rounded off form and added so you never get the accurate result .. so if you want pure or accurate result than kahan rules are good for you .

but if you love speed than IEEE-754 is best for you , because in IEEE-754 we all just depend upon .. quickness and we predict the result in IEEE-754 we do not use the accurate or depend upon accurate result .

 ********** now I think in some cases IEEE-754 is used for user benefit **********

Tuesday 11 October 2011

beautiful ... fluid mechanics is also used in JAVA ...


                                             

method overloading is another worse part of java ...

for me java is best language but i want to say a quote that " Java need patience " thats true if you want to become master in Java

and explore your knowledge ... i choose this easy topic because i think 30% people in this world or more than 30% people thinks and live with satisfaction but i do not want to waste my life with satisfaction .... so for me satisfaction is the key to success

now my topic is .... i totally disagree with method overloading ...and i make those type of codes which never uses the case where overloading is performed

now why overloading is worth .. or useless take a look and just dip on it ...
java is built for man ... means for human environment ...
now took "+" operator in java ...
and add 2+3 = 5 ok i am happy with it ..
now add "what"+"game" = "whatgame" ...
now think how ... "+" operator can add a thing which is totally different ...  no relation in human's life ..
now what i want to say  totally different ... so if anyone say that ... creating code is good or our seniors says that hey gentleman create a code for this this this ..  and you or i am happy that we are using or just creating codes for just your program ...

but i am not a developer and i love java it is like my parents ... so i abuse my parents by doing wrong tasks ...
so  "+" operator hurts java .... and a another factor ... for java poorness ...

so please work like a efficient or a genius for Java ...



Sunday 9 October 2011

every time compiler delete unused stacks why ?

every time when machine starts it create stacks and every time when we switch off our machine ( JVM ) it deletes all its stacks .

yes what are you thinking for the answer of this question is true .. that memory allocated for that for program should be deleted ... i will say yes but take a case :

create a for loop :-
int i ;
for( i = 0 ; i < 100 ; i ++ )
{
  ;
}

now for this program think how much memory is allocated .
in your mind you are thinking that not too much just some addressing because , starting address is stored
or a return address for this program ... yaa thats true in your sense ...

but compiler is too different from our sense because it has to create something which is accepted by machine .
now think like a compiler and dream how much memory will allocate if each instruction takes 2 byte ....
please think ... think ... think ... because when you think your mind makes some move and increases your level .

if i say that this program will take minimum ------ bytes than you will say that how ...
but this is true .... because every time a instruction is loaded from frame and stored into operand stack ... so two instruction is used for only 1 value and every time the old value is fetched from operand stack and every time it is incremented and loaded back into operand stack than 3 instruction is used for still one operation
so minimum 10 bytes which is allocated to 1 instruction and there are total 100 instruction and task are performed and total 1000 bytes means 1kb memory only for a for loop .... wow ( i love it )

now i think this is enough for finding why stack is deleted and for me and for compiler 1 kb is enough but not for you ,,, so please spent your sometime in machine representation because every time you will find something great which will make you different from others .

and learn more and google more because life is not only for fun you are here for doing something not for wasting your rime ...

Big endian representation is the reason behind java's platform independency

we all know that java is famous for platform independency , but do you ever think that how a machine or just a software can be a reason for some thing ... so in JVM there is something pretty interesting which create JVM as platform independent language ...

" so please find something in this world which gives you some confidence and proves you as a engineer . "

i tried my best and i am true to 70-80 % but still i am a learner and still i am working  .
now in java  , JVM is every thing so , inside JVM there is a endianship , which is representation of any thing ... but this is a heavy thing to understand  ...

now first understand what is language-text and data 

language-text is like "i love my nature" means  " human is saying that he loves his nature " , there is a meaning of this thing , and please write this text without any sense "i l o v e m y n a t u r e" dont consider the meaning of this text now read it ... will you understand the text ... and my answer is no ...

take another example "|0" understand it 
:- |0 - can be - 10
:- |0 - can be - io (input output)
:- |0 - can be - I/O ( input output devices)

we have three things which are related to |0 now how we differentiate between these three ...
and the answer is , there must be some interpreter which will make sense or will understand it means interpreter which makes a sense that |0 is for io and is for 10 ...

and the same case is also followed in case of java's class file .
now for this we have a compiler or interpreter which makes class file for java program ...
now think in class file ... arrange your class file according to your mind and arrange the data "tushar" in hexadecimal form .
                             tushar --- 0xtu 0xsh 0xar { only for your understanding }
and some another person will arrange this name as
                             tushar --- 0xsh 0xtu 0xar { only for your understanding }

now think when machine will understand this code or when resources are allocated to this data then what will happen ... machine will understand this thing differently and perform those task which are never expected from machine ... now now now the problem is in machine so surely there will be solution ...

so for this you have to create something from where you will get some definite thing which can be easily understandable by any machine because our machine is also is typical type of thing means all follow different things ...

than what type of things they are ...
see what is published or provided to machine is never accepted in the same way ... means we generally add things from left to right but machine accepts those things from right to left ...

now the time is to understand what is endian representation ... 
two types of endian in representation ..
big-endian 
little-endian 

java uses big-endian but why , because java or class file highly depend upon representation 
because JVM heavily depend upon storage and debugging and by endian representaion we provide these two things easily .

but sorry i can only explain .. endian representation because i can not find any thing related to debugger and i can not work for debugging in ma machine .

but please now look at memory storage
use big-endian for representing 0x1234 
0x34 --- will store at 0 address
0x12 --- will store at 1 address 
but why because the higher order bit is stored in base ..

but in little endian 0x1234 
0x12 is stored in 0 address
0x34 is stores in 1 address 

so thats why 123400 and 1234 and 12340000 is equal numbers in little endian 
but in big-endian they all are different 
because big-endian believe in strictness or in restrictness ...

so class file is built from or used big-endian representation ... for strict storage and restrictness of memory .
now JVM who will understand this data ... 
means when ever we will compile our program ... we get a constant thing means that thing is represented by big-endian ... and now any jvm or any machine can understand it ... because jvm is also built from big-endian representation ... 

" so i simple words BIG-ENDIAN representation is the reason behind java's platform independency "

     

Friday 7 October 2011

how next instruction is fetched in your machine ...

for me the most beautiful thing in this world is machine ( computer machine ) ... i hate girls because i love machine ... thats my opinion and i love when i live with my opinion .



Wednesday 5 October 2011

machine language difference between abstract and interface

please closed your book and take a dip in this and surely you will find something different ....