Menu

#6 sqrt function hangs application

open
Math Engine (6)
9
2004-05-05
2004-05-05
ecoman
No

See the following code snippet :
org.dutour.jmfp.math.MathFP.setDefaultRenderPrecision(2);
long num1 = 625;
org.dutour.jmfp.math.MathFP mfp1 = new
org.dutour.jmfp.math.MathFP(num1);
java.util.Calendar cal =
java.util.Calendar.getInstance();
System.out.println("start sqrt = " +
cal.get(java.util.Calendar.HOUR_OF_DAY) + ":" +
cal.get(java.util.Calendar.MINUTE) + ":" +
cal.get(java.util.Calendar.SECOND));
mfp1.sqrt();
cal = java.util.Calendar.getInstance();
System.out.println("end sqrt = " +
cal.get(java.util.Calendar.HOUR_OF_DAY) + ":" +
cal.get(java.util.Calendar.MINUTE) + ":" +
cal.get(java.util.Calendar.SECOND));
System.out.println("sqrt of " + num1 + " =
" + mfp1);

long num2 = 823;
org.dutour.jmfp.math.MathFP mfp2 = new
org.dutour.jmfp.math.MathFP(num2);
cal = java.util.Calendar.getInstance();
System.out.println("start sqrt = " +
cal.get(java.util.Calendar.HOUR_OF_DAY) + ":" +
cal.get(java.util.Calendar.MINUTE) + ":" +
cal.get(java.util.Calendar.SECOND));
mfp2.sqrt();
cal = java.util.Calendar.getInstance();
System.out.println("end sqrt = " +
cal.get(java.util.Calendar.HOUR_OF_DAY) + ":" +
cal.get(java.util.Calendar.MINUTE) + ":" +
cal.get(java.util.Calendar.SECOND));
System.out.println("sqrt of " + num2 + " =
" + mfp2);
mfp2.unregister();

When executing this code...
start sqrt = 11:25:15
end sqrt = 11:25:15
sqrt of 625 = 25.00
start sqrt = 11:25:15
... I am still waiting for the code to complete and its
11:30

Comments :
- The sqrt (square root and not square of number as
described in Javadoc).
- A 'round' function which rounds the number to the
decimal point is required in the MathFP class.
- When the sqrt is being calculated, the precision must
be taken into account and calculation of sqrt be only
till the decimal point and the value of the MathFP,
rounded off.

Discussion

  • ecoman

    ecoman - 2004-05-05
    • priority: 5 --> 7
     
  • ecoman

    ecoman - 2004-05-05
    • priority: 7 --> 8
     
  • ecoman

    ecoman - 2004-05-05
    • priority: 8 --> 9
    • assigned_to: nobody --> looky
     

Log in to post a comment.