Re: Variablen in Methode nicht zulaessig




Stefan Ram schrieb:

> Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx> writes:
> > public static double hypotenuse(double a, double b)
> > {
> > // berechnet die Hypotenuse im rechtwinkligen Dreick
> > double x;
> > x =Math.sqrt(a*a+b*b);
> > x =Math.round(x*100.0)/100.0;
> > return x;
> > }
>
> Due to the rounding, the comment and the name of the method
> now is misleading. Assume, a = 3E-17 and b = 4E-17, the result
> according to the comment should be 5E-17, but I am afraid it
> might be significantly different.
>
> There is also another possible implementation:
>
> public static double hypotenuse( final double a, final double b )

I'm sorry, it was a misstake, have no language watch
> { return java.lang.Math.hypot( a, b ); }

.



Relevant Pages

  • Re: Problem comparing double values
    ... > better than the epsilon test even if it will probably be ever so ... > of its own due to its use of Banker's Rounding. ... VB.Net: "Fool me once..." ... Prev by Date: ...
    (microsoft.public.vb.general.discussion)
  • Re: Stop numbers from Rounding
    ... > How do you stop numbers from rounding to whole numbers in Access 2003. ... > NealJH ... I do not reply to personal e-mail ... Prev by Date: ...
    (microsoft.public.access.gettingstarted)
  • I am trying to round up to the nearest 25 cents
    ... I am trying to round a money value to the nearsest 25 cents and it keeps ... rounding to the nearest dollar HELP ... Prev by Date: ...
    (microsoft.public.excel.newusers)
  • Another rounding issue
    ... Here's another rounding issue I just discovered: ... Without preformatting cell D2 it defaults to GENERAL and unexpectedly ... Biff ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: How can formulas be used to create another formula?
    ... I have found out what it is, very simple - rounding! ... "JE McGimpsey" wrote: ... >> To be honest it's that simple I can't understand what i'm doing wrong! ... Prev by Date: ...
    (microsoft.public.excel.misc)