Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Been through Hell? Whaddya bring back for me?" -- A. Brilliant


devel / comp.unix.shell / Kornshell - available predefined math functions

SubjectAuthor
* Kornshell - available predefined math functionsJanis Papanagnou
`- Re: Kornshell - available predefined math functionsChris Elvidge

1
Kornshell - available predefined math functions

<s491sl$ajh$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3567&group=comp.unix.shell#3567

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Kornshell - available predefined math functions
Date: Sat, 3 Apr 2021 08:27:33 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 23
Message-ID: <s491sl$ajh$1@news-1.m-online.net>
NNTP-Posting-Host: aftr-62-216-206-167.dynamic.mnet-online.de
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1617431253 10865 62.216.206.167 (3 Apr 2021 06:27:33 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Sat, 3 Apr 2021 06:27:33 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Mozilla-News-Host: news://news.m-online.net:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 3 Apr 2021 06:27 UTC

Implementing some arithmetic code in Kornshell I used the ceil()
function in an arithmetic context without thinking, and it worked!
Only afterwards I hesitated and wondered about this function being
available. (I am using ksh Version AJM 93u+ 2012-08-01.)

Korn's book mentions only about a dozen functions but my man page
says:

"Any of the following math library functions that are in the C math
library can be used within an arithmetic expression:

abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos
cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmin
fmod hypot ilogb int isinf isnan j0 j1 jn lgamma log log2 logb
nearbyint nextafter nexttoward pow remainder rint round sin sinh
sqrt tan tanh tgamma trunc y0 y1 yn"

A lot more functions than mentioned in the book, but ceil() is also
not listed.

Can any function from the C math library be used?

Janis

Re: Kornshell - available predefined math functions

<s49hih$7ae$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3571&group=comp.unix.shell#3571

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Kornshell - available predefined math functions
Date: Sat, 3 Apr 2021 11:55:10 +0100
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <s49hih$7ae$1@dont-email.me>
References: <s491sl$ajh$1@news-1.m-online.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 3 Apr 2021 10:55:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3e1c64ccb2e894c981e1dc82ae942770";
logging-data="7502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AuvUWJWyYXHmH4x0rUDAqNIBxXfxlQdc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:VC8WecOCxaAjyjJ/cizgUqxXqmk=
In-Reply-To: <s491sl$ajh$1@news-1.m-online.net>
Content-Language: en-GB
 by: Chris Elvidge - Sat, 3 Apr 2021 10:55 UTC

On 03/04/2021 07:27 am, Janis Papanagnou wrote:
> Implementing some arithmetic code in Kornshell I used the ceil()
> function in an arithmetic context without thinking, and it worked!
> Only afterwards I hesitated and wondered about this function being
> available. (I am using ksh Version AJM 93u+ 2012-08-01.)
>
> Korn's book mentions only about a dozen functions but my man page
> says:
>
> "Any of the following math library functions that are in the C math
> library can be used within an arithmetic expression:
>
> abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos
> cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmin
> fmod hypot ilogb int isinf isnan j0 j1 jn lgamma log log2 logb
> nearbyint nextafter nexttoward pow remainder rint round sin sinh
> sqrt tan tanh tgamma trunc y0 y1 yn"
>
> A lot more functions than mentioned in the book, but ceil() is also
> not listed.
>
> Can any function from the C math library be used?
>
> Janis
>

The ksh man page in Slackware14.2 mentions ceil

$ ksh --version
version sh (AT&T Research) 93u+ 2012-08-01

Any of the following math library functions that are in the C math
library can be used within an
arithmetic expression:

abs acos acosh asin asinh atan atan2 atanh cbrt ceil copysign
cos cosh erf erfc exp exp2 expm1
fabs fpclassify fdim finite floor fma fmax fmin fmod hypot ilogb
int isfinite sinf isnan isnor‐
mal issubnormal issubordered iszero j0 j1 jn lgamma log
log10 log2 logb nearbyint nextafter
nexttoward pow remainder rint round scanb signbit sin sinh sqrt
tan tanh tgamma trunc y0 y1 yn
In addition, arithmetic functions can be define as shell
functions with a variant of the func‐
tion name syntax,

function .sh.math.name ident ... { list ;}
where name is the function name used in the arithmetic
expression and each identifier,
ident is a name reference to the long double
precision floating point argument. The
value of .sh.value when the function returns is the value
of this function. User defined
functions can take up to 3 arguments and override C math
library functions.

--
Chris Elvidge
England

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor