As you know I have garnered a great interest in using integer maths to do some fixed point calculations.
Here is my next incarnation, calculating PI to 3 and 12 decimal places using 2 of the simplest of series to obtain the value.
First is the Gregory-Leibniz series which is notoriously SSLLOOWW but would be useful for 16 bit systems.
Second is the Nilakantha series which is much, MUCH faster and used to show the 12 places of decimals in 64 bit systems.
This carries on from my previous fun pieces on here.
Read the code for more information.
Results OSX 10.14.3, default bash terminal, originally calling dash.
Enjoy...
Bazza...
This User Gave Thanks to wisecracker For This Post:
Hi guys...
I am loving this integer maths thing.
64 bit systems are certainly easier than 32 bit, but hey, I don't intend to leave out my fav' platform.
Using one of the 'Brothers' methods, URL inside the code.
#!/bin/sh
#
# #!/usr/local/bin/dash
# e_constant.sh
# Brother's formula .
#... (2 Replies)
A recent Python upload on another site gave me the inspiration to do an unusual bash version...
This is a little tongue-in-cheek but an enjoyable bit of fun.
It took around 11 seconds to prove 90000000000 had a perfect square of 300000...
It is a stand alone program and has a degree of... (23 Replies)
Heya
Ever wanted to have some basic stats of your projects?
Like:
./stats.sh
########################################
Project stats for "tui"
########################################
260 kb in bin
24 kb in conf.etc
12 kb in conf.home
32 kb in docs/samples
176 kb in docs/wiki
280... (5 Replies)
Hi All,
I have the following time stamp data in 2 columns
Date TimeStamp(also with milliseconds)
05/23/2012 08:30:11.250
05/23/2012 08:30:15.500
05/23/2012 08:31.15.500
.
.
etc
From this data I need the following output.
0.00( row1-row1 in seconds)
04.25( row2-row1 in... (5 Replies)
I would like to extract a number from $0 and calculate if it can be devided by 25. Though the number can also be less then 25 or bigger than 100. How do i extract the number and how can the integer be calculated?
String:
"all_results">39</span>I am looking for the number between "all_results"> ... (5 Replies)
Hi All
I've made a few scripts which using GDAL extract the value of a pixel within a given raster. The purpose is to work out the combine value of every pixel. I thought there may have been an easier way to do this but alas!
The code below extracts the pixel value at position X Y. The... (3 Replies)
Hello,
I'm trying to write a while loop for a decimal value in tcsh which I know can't be done. Instead I want my increments to be one order of magnitude too large and then divide it by 10 when I use the variable. However, I don't know how to divide my variable and set it as another.
set... (1 Reply)
if input to the perl program is ' ( p * ((a+b) * (c+d))) + q ' it shuld give the output as ' pac + pad + pbc + pbd + q ' .can anyone suggest a way to do this ? (7 Replies)
Heres a script i wrote as a bit of practise. What it does is insert a line in the middle of a file. The line being $1 and the file being $2
#!/bin/bash
rm tempfile
touch tempfile
count=1
linenum= `wc -l < $2`
if
then
echo $1 >> $2
else
even=`expr "$linenum" % 2`
if
then... (3 Replies)