Java, do variables associated with an object persist? BigInteger Example -
i'm having bit of trying figure if variables used when creating object persist in java.
specifically i'm looking @ biginteger. if i'm reading code correctly looks instead of doing addition etc. on bit bit basis number broken 32bit words allows faster operation. have not been able figure out whether 32bit word representation , other variables (mag[], signum etc.) have created everytime method used on biginteger or if somehow persists in cache , remain associated particular biginteger once has been created.
i guess you're looking @ code:
1054 public biginteger add(biginteger val) { 1055 int[] resultmag; 1056 if (val.signum == 0) 1057 return this; 1058 if (signum == 0) 1059 return val; 1060 if (val.signum == signum) 1061 return new biginteger(add(mag, val.mag), signum); 1062 1063 int cmp = intarraycmp(mag, val.mag); 1064 if (cmp==0) 1065 return zero; 1066 resultmag = (cmp>0 ? subtract(mag, val.mag) 1067 : subtract(val.mag, mag)); 1068 resultmag = trustedstripleadingzeroints(resultmag); 1069 1070 return new biginteger(resultmag, cmp*signum); 1071 }
the mag
, signum
refer fields in each instance of biginteger
. not calculated on demand, part of implementation of biginteger
. method of access (not function invocation) indicates it's merely accessing storage location.
Comments
Post a Comment