Search Results

Search: Posts Made By: Corona688
Forum: OS X (Apple) 12-12-2018
50,295
Posted By Corona688
Naturally 0.00094 is zero when truncated to three...
Naturally 0.00094 is zero when truncated to three fixed decimal places. That is not "edge case" -- it's supposed to do that.

If you want more decimal points in my code, change DP and MOD.
Forum: OS X (Apple) 12-11-2018
50,295
Posted By Corona688
BASH mandelbrot set: DP=8 MOD=1 while [[...
BASH mandelbrot set:

DP=8
MOD=1
while [[ "${#MOD}" -le "${DP}" ]]
do
MOD="${MOD}0"
done

ESCAPED=0

function ftofix { # ftofix OUTPUTNAME "3.14"
local _N="0"
...
Forum: OS X (Apple) 12-10-2018
50,295
Posted By Corona688
DP=3 MOD=1000 function ftofix { #...
DP=3
MOD=1000

function ftofix { # ftofix OUTPUTNAME "3.14"
local _N="0"
local D=0
local X
local Y

# Convert "VAR" "-.3" into "VAR" "-" "0.3",...
Forum: OS X (Apple) 12-10-2018
50,295
Posted By Corona688
There was a bug in my version above. Arithmetic...
There was a bug in my version above. Arithmetic involving negative numbers worked, the edge case was the display of them. One 'edge' was that I completely forgot to display the sign, at all, ever. ...
Forum: OS X (Apple) 11-21-2018
50,295
Posted By Corona688
Here is the fixed point arithmetic code for a ...
Here is the fixed point arithmetic code for a fixed point basic calculator for DASH... Cheers.

#!/bin/bash
# Fixed point arithmetic
DP=3 # Decimal Places
MOD=1000 # 1 * 10^DP

function...
Forum: OS X (Apple) 11-08-2018
50,295
Posted By Corona688
Beware that not only IFS is preserved -- every...
Beware that not only IFS is preserved -- every variable is preserved. Variable assignments inside the new shell don't copy into the old one. It's just like running commands behind a pipe.
Forum: OS X (Apple) 11-08-2018
50,295
Posted By Corona688
I did? It is set -- arg1 arg2 arg3 ... which...
I did? It is set -- arg1 arg2 arg3 ... which sets the $1 $2 $3 variables.

If you run it like set -- $variable it will split upon IFS, which is whatever you please, giving an easy way to split a...
Forum: OS X (Apple) 11-07-2018
50,295
Posted By Corona688
I'm sure DASH can divide and multiply absolutely...
I'm sure DASH can divide and multiply absolutely fine. It has * and /.

I noticed, but the way you're doing it is perhaps the hardest possible way. If you just keep your number as an integer,...
Forum: OS X (Apple) 11-06-2018
50,295
Posted By Corona688
Here's a quick bash-only version for positive...
Here's a quick bash-only version for positive numbers. The trick is reading the values in. Once you do that the rest is straightforward.

DP=3
MOD=1000

function readnum {
IFS="."...
Forum: OS X (Apple) 11-06-2018
50,295
Posted By Corona688
I misread your post as dash misbehaving rather...
I misread your post as dash misbehaving rather than zsh, but anyway - I don't mean the shell has floating point. I mean shell printf could use it as a temporary intermediate to implement %f. potato,...
Forum: OS X (Apple) 11-06-2018
50,295
Posted By Corona688
My suggestion would be to eliminate these...
My suggestion would be to eliminate these floating point conversions, and just use integer math. For three decimal points you'd do

SIGN="+"
if [ "$NUM" -lt 0 ]
then
NUM=$((-NUM))
...
Forum: OS X (Apple) 11-06-2018
50,295
Posted By Corona688
Your use of printf "%f" is perhaps begging for...
Your use of printf "%f" is perhaps begging for trouble, that may convert to floating point and back. And even 64-bit floating point doesn't have the exactness of a 64-bit integer, some of those 64...
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 02:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy