PDA

View Full Version : Don't Understand the Algorithm behind the question


victoria_1018
10-04-2003, 04:16 AM
Hi,
I am a java beginner and currently working on a java program.
However, I don¡¦t really understand the algorithm and the structure behind this question.
I know that I have to create an Array to store the number and will have to perform some shifting of decimal place(s) to fulfill the task.
Would anyone give me give idea on how the algorithm like.
Thanks

The Question

Class VLFN (Very-Large-Floating-Number) models positive infinite precision Floating Number. The class supports the operations as shown in the following codes:
VLFN i1 = new VLFN();
// Construct a VLFN that represents the number 0.0

VLFN i2 = new VLFN(¡§1234567.8901234567890123456789¡¨);
// Convert the string into a VLFN

VLFN i3 = new VLFN(¡§0.123456789¡¨);
// Convert the string into a VLFN

VLFN i4 = i2.add(i3);
// return the sum of i2 and i3; i2 and i3 not changed.

VLFN i5 = i2.shiftLeft(3);
// return i2*103; i2 not changed.

VLFN i6 = i2.shiftRight(4);
// return i2 / 104; i2 not changed.

String s = i2.toString();
// return a string representation of the digits in the VLFN.

int b = i2.compare(i3);
// return ¡V1 if i2 < i3
// return +1 if i2 > i3
// return 0 if i2 = i3

Jason
10-06-2003, 10:11 PM
though we wont solve hw questions here you might try looking harder at your program. Aparently you need to create a new structure VLFN that holds your number and will then have the manipulation methods such as compare and all that. So there is no algorithm here...


Jason