Simple Scientific calculator for ADE, the UNIX environment for the AMIGA A1200(HD).
ADE is a UNIX environment for the ancient AMIGA A1200. By default this does NOT have the 'bc' command line calculator.
Although I did a DEMO code to create a C source and compile it under python 1.4.0 and ADE using ksh88 and the gcc of the day, I decided to create this baby that requires no Python and compilation at all. 'bc' can be obtained from AMINET but is is so convoluted that I don't use it.
This incarnation uses 'awk' purely as a calculator for complex floating point, (basic scientific), calculations and is a shell script.
This was developed on this MBP OSX 10.14.3 and tested in the AMIGA environment using the above.
Results on both this MBP and the AMIGA, not tested in Linux flavours:
I think this is good enough for the average user...
These 2 Users Gave Thanks to wisecracker For This Post:
A very practical use of scicalc and this will be the last upload...
I am creating an audio function generator and wanted to use ASCII only for all of the waveforms so that a simple arbitrary waveform could be created using a text editor, and all other waveforms can be edited too.
Well this is not fast but generates a sinewave in pure ASCII only. It is a practical use of 'scicalc'.
Results; editing for both for loops:
How does it work:
First things first, there are 95 normal printable ASCII characters from ASCII 32 decimal " ", and ASCII 126 decimal "~".
The _centreline_ character is ASCII 79 decimal "O", (not ZERO but capital O).
So we have three conditions to take care of, the minimum value must be no less than ASCII 32 " ", the centreline pseudo-DC ASCII 79 "O", (Direct Current level), and finally the maximum value must be no more ASCII 126 "~".
Now consider the expression "(((sin((${ANGLE}*pi)/180)+1)/2.0)*94)+32" ...
There is no need for any start and end parentheses as this is catered for inside 'scicalc'; it does not matter if you add them though.
As 'sin(x)' from 0 to 360 degrees goes from 0 to +1 to 0 to -1 and finally back to 0 again we have to remove the negative part so +1 is added to every calculated result.
This now moves the values to 1 to 2 to 1 to 0 and finally back to 1 again.
When that is done those values are divided by 2 to give the range 0.5 to 1 to 0.5 to 0 and finally back to 0.5.
0.5 is now the centreline, or DC, and this is now multiplied by the (number_of_printable_characters - 1).
We are not done yet; as this will go from 0.0 to 94.0 then the whole has to be shifted up so 0.0 becomes 32.0 and 94.0 becomes 126.0 so 32 must be finally added, and voila, using the script 8 or 64 byte ASCII single cycle pseudo-sinewave is created.
I hope this is lucid enough.
Note that 'printf "%.0f" ' is used to create the integer values, see the code...
(And also doing this manually would take ages.)
Enjoy...
Bazza.
Last edited by wisecracker; 07-22-2019 at 01:49 PM..
Reason: Code tags, adding spaces.
Well, I think I must have this for Christmas!
Python on the Casio FX-CG50 with Data Acquisition
YT: CASIO fx-CG50 E-CON4 Movie
YT: Update Your CG50 Operating System. Now Includes Python! (OS update)
This is a great deal on Amazon!
See YT Code Tag Video (9 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known/data:
Script a simple calculator. In the command line enter the script file
/home/etc/mycalc or /home/etc/mycalc 1 +... (6 Replies)
I am trying to make a calculator. The user Enters number 1, chooses and operation, enters number 2, then chooses another operation or for the answer to be displayed.
eg. 1 + 1 = or 1 + 1 + 2 + 1 =
Both of these should be possible.
#!/bin/bash
read -p "what's the first number? " n1... (3 Replies)
Hi, I am trying to make a maths calculator that:
1. Prompts the user for a number.
2. Prompts the user for an operation (add, subtract, divide or multiply)
3. Prompts the user for a number.
4. Prompts the user for another operation (same as above) OR the option to get the result for the... (4 Replies)
Hi All,
In our code we are using below code to calculate the UNIX Epoch Time from the time stamp present in the file.
Can any one explain how the DC operates in below command and how we calculate the UNIX EPOCH time from this.
Date incide the file is 20:26:51
Output we get is 1289943554... (3 Replies)
HI ,
In the below script I am trying to return the value of the environment variable TIBCO_HOME to the caller
#! /usr/bin/csh
set VAR_NAME=$1
echo VAR_NAME
On the aix console.. set to setenv TIBCO_HOME /app/tibco
When I execute the script... myscript.sh TIBCO_HOME, the script... (5 Replies)