473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

for loop problem

method "adding" don't work why??? i think this is in for loop....help me!!

public class Hugeinteger{

private int[] hugeint;
private int longe;
private int[] result;
private boolean comparison;

public Hugeinteger(int[] num)
{
// initialise instance variables
comparison = false;
hugeint = new int[40];
int j = num.length-1;
for(int i=39;i<=hugeint.length-num.length;i--){
hugeint[i] = num[j];
j--;
}
for(int k=39-num.length;k>=0;k--){
hugeint[k]=0;
}
longe = hugeint.length-num.length;
}


public Hugeinteger adding(Hugeinteger r){
//Hugeinteger result = new Hugeinteger();
result = new int[40];
int e=0;
if(this.hugeint[this.longe]<0 && r.hugeint[r.longe]<0){
this.hugeint[this.longe]*=-1;
r.hugeint[r.longe]*=-1;
e=1;
}
if(this.hugeint[this.longe]<0 || r.hugeint[r.longe]<0){
subtract(r);
}

for(int i=39;i>=0;i--){
result[i] = this.hugeint[i]+ r.hugeint[i];
if(result[i]>9){
result[i]= result[i]-10;
hugeint[i-1]+=1;
}
else{
result[i] = this.hugeint[i]+ r.hugeint[i];
}
}
if(e==1){
result[longe]*=-1;
}
return new Hugeinteger(result);
}
Apr 6 '12 #1
2 1727
Hello, I think this might be the reason why:
Expand|Select|Wrap|Line Numbers
  1. public Hugeinteger adding(Hugeinteger r){
  2. //Hugeinteger result = new Hugeinteger();
  3.  
It looks like you have "//" comment marks in the middle of your function statements...?
Apr 6 '12 #2
no!! problem was in for loop i should write...
for(int i=39;i>=hugeint.length-num.length;i--)

thank you!
Apr 6 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Alexander | last post by:
Hello I am new to php & MySQL - I am trying to retrieve some records from a MySQL table and redisplay them. The data in list form looks like this: Sample_ID Marker_ID Variation ...
5
by: B. Chernick | last post by:
Is this a bug or just bad programming? I've never encountered this problem before. (Bare minimum sample form to illustrate.) I've also tried this with a class. Same result. The error is: For...
0
by: adriann | last post by:
I have a strange problem whereby an attempt at a looped SQL query only passes successfully once. I get the error.. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result...
4
by: puafo | last post by:
Hi everyone, I am relativly new to asp and am having a problem with a loop. This is my select statement: strSql = "SELECT newsletters.*, homePage.*, pointsTable.*,...
5
by: simiabin | last post by:
i am new to asp.... i am facing a problem in for loop what i want is, if the record does not exist loop should execute insert query else it should go to update query .. while i try to execute...
1
by: saytri | last post by:
I have a problem with this code. I'm, doing a quiz, and the questions are stored in a binary file. My problem is how am i going to compare the answers entered by the user to the correct answers. The...
1
by: shredder249 | last post by:
Hi, I have a list box (called genredelete) and i'm trying to write a procedure to delete all the selected items in the list box. The code i have written to do this is as follows: Dim...
1
by: 17beach | last post by:
I am running a web application and processing some data within a loop under certain situation s I would like a button to be displayed and the user to run the code behind the button and then return to...
7
by: Dave | last post by:
Hey there, having a bit of problem iterating through lists before i go on any further, here is a snip of the script. -- d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5 c5...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.