diff --git a/Doc/Sd1/LanguageFundamentals/languageFundamentals.xml b/Doc/Sd1/LanguageFundamentals/languageFundamentals.xml index 1027170756bef104679f98b63eafe86aac0f16c2..5d5b286175596a463054caa014372041a593d8e6 100644 --- a/Doc/Sd1/LanguageFundamentals/languageFundamentals.xml +++ b/Doc/Sd1/LanguageFundamentals/languageFundamentals.xml @@ -5720,9 +5720,35 @@ System.out.println(2147483647 + 1L);</programlisting> result and propose a solution.</para> <tip> - <para>You will have to replace the <quote>==</quote> operator - by something more appropriate addressing limited arithmetic - precision.</para> + <itemizedlist> + <listitem> + <para>You will have to relax the exact <quote>==</quote> + operator by a »being close to each other« relation + addressing the limited arithmetic precision.</para> + </listitem> + + <listitem> + <para>The <methodname + xlink:href="https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Math.html#abs(double)">Math.abs()</methodname> + method calculates the absolute value:</para> + + <informaltable border="1"> + <tr> + <th>Code</th> + + <th>Result</th> + </tr> + + <tr> + <td valign="top"><programlisting language="java">System.out.println(Math.abs(10.7)); +System.out.println(Math.abs(-10.7));</programlisting></td> + + <td valign="top"><screen>10.7 +10.7</screen></td> + </tr> + </informaltable> + </listitem> + </itemizedlist> </tip> </question>