## Gobsmacked by ksh93 floating point arithmetic.

# 15
Hi C688...
This will probably attach itself to my previous...

Thanks, much like my reply above...

I can see it now.
 wisecracker View Public Profile for wisecracker Find all posts by wisecracker
# 16
The for-loop comes from C, where it follows the form

which does effectively this:

It's usually used for(var=0; var<10; var++) but any valid expression will do. Most languages with for() loops allow them to be flexible like that, though few languages can cram as many things into one expression as C

In the BASH/KSH adaptation, you can put anything inside each statement that you might put inside a (( )) block, including nothing.
 Corona688 View Public Profile for Corona688 Visit Corona688's homepage! Find all posts by Corona688
# 17
OK, using Corona688's code for SINE we now have Sin(), Cos(), NthRoot() and Sqrt() functions.
The 'e' and 'PI' constants are to 17 decimal places, NthRoot() and Sqrt() to 16 decimal places and Sin() and Cos() to 8 decimal places.
These precisions are good enough for basic mathematical tasks, after all KSH93 was not designed to send a spacecraft to Neptune. <wink>
Results on OSX 10.13.6, default bash terminal calling ksh.
Note the code is sourced into current ksh shell...
Hope you are all enjoying this exercise in futility... ;oD
This User Gave Thanks to wisecracker For This Post:
 wisecracker View Public Profile for wisecracker Find all posts by wisecracker

## BC calculation for floating (invalid arithmetic operator )

Hi, I wish to compare the CPU LOAD 1 min with 5mins and 15mins. If 1 min's CPU LOAd spike 3% compare to 5 mins or 15 mins CPU Load, it is warning. If 1 min's CPU LOAd spike 5% compare to 5 mins or 15 mins CPU Load, it is critical. However I received following code error, I google it and...

## floating point arithmetic operation error

I am writing a script in zsh shell, it fetchs a number from a file using the awk command, store it as a variable, which in my case is a small number 0.62000. I want to change this number by multiplying it by 1000 to become 620.0 using the command in the script var2=\$((var1*1000)) trouble is...

## Floating Point

Anyone help me i cant found the error of floating point if needed, i added the code complete #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> typedef struct { int hh; int mm; int ss; char nom; int punt; }cancion; typedef struct...

## Arithmetic in floating point

is it not possible to simply di aritmetic without using bc or awk i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant...

## floating point numbers in if

# if > then > echo "1" > else > echo "2" > fi -bash: How can i compare floating point numbers inside statement?

## Floating point Emulator

what is floating point emulator(FPE)? where and why it is used?

## Floating point error in C

Hi, see the simple code below double i; i=8080.9940; printf(" val :%.30f\n",i); output i m getting is val :8080.993999999999700000000000000 when i m expecting val :8080.9940 what happens?how can i avoid it? thanks...

## Rounding off the value of Floating point value

Hello, i have some variables say: x=1.4 y=3.7 I wish to round off these values to : x = 2 (after rounding off) y = 4 (after rounding off) I am stuck. Please help.

## floating point problem

Hi all! Hi all! I am working with a problem to find the smallest floating point number that can be represented. I am going in a loop ,stating with an initial value of 1.0 and then diving it by 10 each time thru the loop. So the first time I am getting o.1 which I wanted.But from the next...