# A fixed point basic calculator for DASH.

**URL:** <https://community.unix.com/t/a-fixed-point-basic-calculator-for-dash/374080>\
**Category:** macOS\
**Created:** [November 5, 2018, 3:24am UTC](https://community.unix.com/t/a-fixed-point-basic-calculator-for-dash/374080 "2018-11-05T03:24:41Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![wisecracker](https://community.unix.com/user_avatar/community.unix.com/wisecracker/32/2800_2.png) [@wisecracker](https://community.unix.com/u/wisecracker)\
**Post date:** [December 12, 2018, 8:28am UTC](https://community.unix.com/t/a-fixed-point-basic-calculator-for-dash/374080/22 "2018-12-12T08:28:05Z")

</div>

Hi Corona688...

This edge case works on my version...  
I have limited my decimal point to 9 decimal places BUT note the non-zero digits start at the 10th decimal place:

```nohighlight
Last login: Wed Dec 12 06:48:08 on console
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./calc .000000000123 + .0000000007
+0.000000001
AMIGA:amiga~/Desktop/Code/Shell> ./calc .000000000923 + .000000000739
+0.000000002
AMIGA:amiga~/Desktop/Code/Shell> ./calc .000000000123 + .000000000123
+0.000000000
AMIGA:amiga~/Desktop/Code/Shell> _

```

I have certainly discovered that it is more difficult than I expected. There is at least one division edge case that is not straightforwards.  
As I stated before python 2.x or 3.x was my friend here...  
But yours in 'bash' gives...  
I have changed 'AA' and 'BB' to:

```nohighlight
AA=0.000945
BB=0.000789

```

There are other edge cases.  
Ignoring the divide case as that is an edge case in itself and is different from the one mentioned above.

```nohighlight
Last login: Wed Dec 12 13:02:10 on ttys000
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./FPMATH_C688.sh
0.000945 * 0.000789 = 0.000
./FPMATH_C688.sh: line 54: (A*MOD)/B : division by 0 (error token is " ")
0.000945 / 0.000789 = 
0.000789 - 0.000945 = 0.000
0.000945 - 0.000789 = 0.000
0.000945 + 0.000789 = 0.000
AMIGA:amiga~/Desktop/Code/Shell> _

```

This is getting more difficult by the version.

--- Post updated at 01:28 PM ---

Hi C688...  
Your mandlebrot probably won't work on the AMIGA, period, as there is no bash for it, only ksh88.  
Nevertheless it looks cool.  
Off to try it out on this machine...  
OSX 10.14.1, default bash terminal.  
I'll be back to let you know...

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [December 12, 2018, 10:30am UTC](https://community.unix.com/t/a-fixed-point-basic-calculator-for-dash/374080/23 "2018-12-12T10:30:50Z")

</div>

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.

[Previous page](https://community.unix.com/t/a-fixed-point-basic-calculator-for-dash/374080.md?page=1)
