How to resolve the algorithm Extreme floating point values step by step in the Groovy programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Extreme floating point values step by step in the Groovy programming language
Table of Contents
Problem Statement
The IEEE floating point specification defines certain 'extreme' floating point values such as minus zero, -0.0, a value distinct from plus zero; not a number, NaN; and plus and minus infinity. The task is to use expressions involving other 'normal' floating point values in your language to calculate these, (and maybe other), extreme floating point values in your language and assign them to variables. Print the values of these variables if possible; and show some arithmetic with these values and variables. If your language can directly enter these extreme floating point values then show it.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Extreme floating point values step by step in the Groovy programming language
Source code in the groovy programming language
def negInf = -1.0d / 0.0d; //also Double.NEGATIVE_INFINITY
def inf = 1.0d / 0.0d; //also Double.POSITIVE_INFINITY
def nan = 0.0d / 0.0d; //also Double.NaN
def negZero = -2.0d / inf;
println(" Negative inf: " + negInf);
println(" Positive inf: " + inf);
println(" NaN: " + nan);
println(" Negative 0: " + negZero);
println(" inf + -inf: " + (inf + negInf));
println(" 0 * NaN: " + (0 * nan));
println(" NaN == NaN: " + (nan == nan));
println("NaN equals NaN: " + (nan.equals(nan)));
You may also check:How to resolve the algorithm Multi-base primes step by step in the Nim programming language
You may also check:How to resolve the algorithm Trigonometric functions step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Horizontal sundial calculations step by step in the Arturo programming language
You may also check:How to resolve the algorithm Vampire number step by step in the Haskell programming language
You may also check:How to resolve the algorithm Random numbers step by step in the Tcl programming language