473,387 Members | 1,721 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,387 software developers and data experts.

help me to understand codes.

281 100+
I can't understand this code...I need somebody to help me to understand this code.please.
This is from MutableBigInteger java core class..

What is this mean? >> // Special case one word numbers .....
Am I right by saying numbers between 0 - 9 as an example?
How about the int x & int y, kindly please gimme examples of them...
Thank you very much
Expand|Select|Wrap|Line Numbers
  1. while ((lb = t.getLowestSetBit()) >= 0) 
  2.         {
  3.             // steps B3 and B4
  4.             t.rightShift(lb);
  5.             // step B5
  6.             if (tsign > 0) 
  7.                 u = t;
  8.             else
  9.                 v = t;
  10.  
  11.             // Special case one word numbers   
  12.             if (u.intLen < 2 && v.intLen < 2) 
  13.             {
  14.                 int x = u.value[u.offset];  // this part
  15.                 int y = v.value[v.offset];    // this part
  16.                 x  = binaryGcd(x, y);  
  17.                 r.value[0] = x;
  18.                 r.intLen = 1;
  19.                 r.offset = 0;
  20.                 if (k > 0)
  21.                     r.leftShift(k);
  22.                 return r;
  23.             }
  24.  
  25.             // step B6
  26.             if ((tsign = u.difference(v)) == 0)
  27.                 break;
  28.             t = (tsign >= 0) ? u : v;
  29.         }
Apr 28 '07 #1
8 1309
JosAH
11,448 Expert 8TB
I can't understand this code...I need somebody to help me to understand this code.please.
This is from MutableBigInteger java core class..

What is this mean? >> // Special case one word numbers .....
Am I right by saying numbers between 0 - 9 as an example?
How about the int x & int y, kindly please gimme examples of them...
Thank you very much
Expand|Select|Wrap|Line Numbers
  1. while ((lb = t.getLowestSetBit()) >= 0) 
  2.         {
  3.             // steps B3 and B4
  4.             t.rightShift(lb);
  5.             // step B5
  6.             if (tsign > 0) 
  7.                 u = t;
  8.             else
  9.                 v = t;
  10.  
  11.             // Special case one word numbers   
  12.             if (u.intLen < 2 && v.intLen < 2) 
  13.             {
  14.                 int x = u.value[u.offset];  // this part
  15.                 int y = v.value[v.offset];    // this part
  16.                 x  = binaryGcd(x, y);  
  17.                 r.value[0] = x;
  18.                 r.intLen = 1;
  19.                 r.offset = 0;
  20.                 if (k > 0)
  21.                     r.leftShift(k);
  22.                 return r;
  23.             }
  24.  
  25.             // step B6
  26.             if ((tsign = u.difference(v)) == 0)
  27.                 break;
  28.             t = (tsign >= 0) ? u : v;
  29.         }
That piece of code tries to determine whether or not such a BigInteger would
fit in a single (primitive) int after a bit of shifting; this implies that all the bits set
to '1' are no further apart than 32 positions; if so the values fit in such an int.

kind regards,

Jos
Apr 28 '07 #2
shana07
281 100+
That piece of code tries to determine whether or not such a BigInteger would
fit in a single (primitive) int after a bit of shifting; this implies that all the bits set
to '1' are no further apart than 32 positions; if so the values fit in such an int.

kind regards,

Jos
In short - it's shifting BigInteger bit positions (and values) until become integer..
sort of...?
Thank You
Apr 28 '07 #3
shana07
281 100+
Sorry, one more question from me, what is the magnitude...and how does it look like?
Thank you again...
Expand|Select|Wrap|Line Numbers
  1. /**
  2.      * Holds the magnitude of this MutableBigInteger in big endian order.
  3.      * The magnitude may start at an offset into the value array, and it may
  4.      * end before the length of the value array.
  5.      */
  6.     int[] value;
Apr 28 '07 #4
JosAH
11,448 Expert 8TB
Here's a question for you: there is no MutableBigInteger class in the core set
of classes in the JSE. Where did you get that class from?

kind regards,

Jos
Apr 28 '07 #5
shana07
281 100+
Here's a question for you: there is no MutableBigInteger class in the core set
of classes in the JSE. Where did you get that class from?

kind regards,

Jos
Yes, there is MutableBigInteger class in the core set.
This is a path to the class in my pc.
C:\Program Files\Java\jdk1.5.0_07\src\java\math

Is there anything wrong in here.....
Apr 28 '07 #6
JosAH
11,448 Expert 8TB
Yes, there is MutableBigInteger class in the core set.
This is a path to the class in my pc.
C:\Program Files\Java\jdk1.5.0_07\src\java\math

Is there anything wrong in here.....
Feel free of course to study all sorts of classes but MutableBigInteger isn't
a publicly available class and therefore there are no API documents for it to
be found in the API documentation, not is the API itself publicly available.
It's just a helper class for internal use only.You (nor I) can use it because
it's only available for other classes in the java.math package.

kind regards,

Jos

ps. why did you unzip that sources zip file?
Apr 28 '07 #7
shana07
281 100+
Feel free of course to study all sorts of classes but MutableBigInteger isn't
a publicly available class and therefore there are no API documents for it to
be found in the API documentation, not is the API itself publicly available.
It's just a helper class for internal use only.You (nor I) can use it because
it's only available for other classes in the java.math package.

kind regards,

Jos

ps. why did you unzip that sources zip file?
Thanks for the good explanation...I like the way you describe, really.
Since you mentioned about API documents, How do you do that?
I really have no idea how to check API docs ...because I use netbeans, so usually if I wanna check where is the method's located, I right click and go to declaration.

So from there I found the GCD method is in java.math package, so I did unzip them just because I need to copy and alter them due to my java class assignments....

Kindly please advise me. thanks
Apr 28 '07 #8
JosAH
11,448 Expert 8TB
Since you mentioned about API documents, How do you do that?
I really have no idea how to check API docs ...
Have a look at this little thread. The eastiest thing
is to download all the API documentation and bookmark it in your browser for
easy access.

kind regards,

Jos
Apr 28 '07 #9

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

Similar topics

5
by: CaliSchmuck | last post by:
I think this is probably simple, but I'm having a problem figuring it out. I have a form that is used to enter data. I want users to be able to enter a zip code in the form, and have the city...
2
by: Paul T. Rong | last post by:
Who can help me to understand the following two queries? They are very useful when you want to show data horizontally. I found it from a Chinese Access website. ...
13
by: Becker | last post by:
1.=========================================== /* a.c */ int x; int y; void main() { f(); printf("%x %x\n", x, y); }
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
4
by: dismantle | last post by:
Hi all, this is my 3rd week in studying VB codes and i came across with this codes from a online tutorial about classes. Public Function MiddleInitial() As String MiddleInitial =...
2
by: ricky | last post by:
Hi, I am student and I am doing a final year project on Zig-bee. I have to write low energy routing algorithms. I need to write routing algorithm for LEACH. If anybody can help with some links...
0
by: fireline1082 | last post by:
Hi every body I am doing a project in which I have a Windows Certificate Authority server and RADIUS server (IAS RADIUS server under windows ) . In this project the clients will login to the...
1
by: nuffnough | last post by:
I have defined two classes with one common field (called code) and several different fields. In class A there is only one instance of any given code as all items are individual. In class B, there...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.