How to resolve the algorithm Real constants and functions step by step in the NetRexx programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Real constants and functions step by step in the NetRexx programming language
Table of Contents
Problem Statement
Show how to use the following math constants and functions in your language (if not available, note it):
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Real constants and functions step by step in the NetRexx programming language
Source code in the netrexx programming language
/* NetRexx */
options replace format comments java crossref symbols nobinary utf8
numeric digits 30
x = 2.5
y = 3
pad = 40
say
say 'Java Math constants & functions:'
say Rexx(' Euler''s number (e):').left(pad) Math.E
say Rexx(' Pi:').left(pad) Math.PI
say Rexx(' Square root of' x':').left(pad) Math.sqrt(x)
say Rexx(' Log(e) of' x':').left(pad) Math.log(x)
say Rexx(' Log(e) of e:').left(pad) Math.log(Math.E)
say Rexx(' Log(10) of' x':').left(pad) Math.log10(x)
say Rexx(' Log(10) of 10:').left(pad) Math.log10(10)
say Rexx(' Exponential (e**x) of' x':').left(pad) Math.exp(x)
say Rexx(' Exponential (e**x) of log(e)' x':').left(pad) Math.exp(Math.log(x))
say Rexx(' Abs of' x':').left(pad) Math.abs(x.todouble)
say Rexx(' Abs of' (-x)':').left(pad) Math.abs((-x).todouble)
say Rexx(' Floor of' x':').left(pad) Math.floor(x)
say Rexx(' Floor of' (-x)':').left(pad) Math.floor((-x))
say Rexx(' Ceiling of' x':').left(pad) Math.ceil(x)
say Rexx(' Ceiling of' (-x)':').left(pad) Math.ceil((-x))
say Rexx(' ' x 'to the power of' y':').left(pad) Math.pow(x, y)
say Rexx(' ' x 'to the power of' 1 / y':').left(pad) Math.pow(x, 1 / y)
say Rexx(' 10 to the power of log10' x':').left(pad) Math.pow(10, Math.log10(x))
-- Extras
say Rexx(' Cube root of' x':').left(pad) Math.cbrt(x)
say Rexx(' Hypotenuse of' 3 'x' 4 'right triangle:').left(pad) Math.hypot(3, 4)
say Rexx(' Max of' (-x) '&' x':').left(pad) Math.max((-x).todouble, x)
say Rexx(' Min of' (-x) '&' x':').left(pad) Math.min((-x).todouble, x)
say Rexx(' Signum of' x':').left(pad) Math.signum((x).todouble)
say Rexx(' Signum of' x '-' x':').left(pad) Math.signum((x - x).todouble)
say Rexx(' Signum of' (-x)':').left(pad) Math.signum((-x).todouble)
say
say 'NetRexx built-in support for numeric data:'
say Rexx(' Abs of' x':').left(pad) x.abs()
say Rexx(' Abs of' (-x)':').left(pad) (-x).abs()
say Rexx(' Sign of' x':').left(pad) x.sign()
say Rexx(' Sign of' x '-' x':').left(pad) (x - x).sign()
say Rexx(' Sign of' (-x)':').left(pad) (-x).sign()
say Rexx(' Max of' (-x) '&' x':').left(pad) (-x).max(x)
say Rexx(' Min of' (-x) '&' x':').left(pad) (-x).min(x)
say Rexx(' Truncate' x 'by' y':').left(pad) x.trunc(y)
say Rexx(' Format (with rounding)' x 'by' y':').left(pad) x.format(y, 0)
You may also check:How to resolve the algorithm Environment variables step by step in the BASIC programming language
You may also check:How to resolve the algorithm Sort an array of composite structures step by step in the Scala programming language
You may also check:How to resolve the algorithm Consecutive primes with ascending or descending differences step by step in the jq programming language
You may also check:How to resolve the algorithm Enforced immutability step by step in the OCaml programming language
You may also check:How to resolve the algorithm Guess the number step by step in the Objective-C programming language