Thursday, January 5, 2017

Multiplying large numbers in bash.

In my saga to glue and manipulate results from my simontool program that emulates the hardware of the Simon Cipher, I have now added a multiplication instruction to my bashbignumbers.sh library.
#!/bin/bash
# Required programs:
BIGNUMBERS=bashbignumbers.sh
if [ ! -f $BIGNUMBERS ]; then
    echo "File, $BIGNUMBERS, not found!"
    exit
fi
source "$BIGNUMBERS"
STRBIN2_MUL="0000010001111000"
SSTRIN1_MUL="0001010000000000"
SRESULT_MUL=$(bashMULbinstring $SSTRIN1_MUL $STRBIN2_MUL) 
echo "$STRBIN2_MUL"  
echo "$SSTRIN1_MUL"        
echo "$SRESULT_MUL"  
The resulting output is:
0000010001111000
0001010000000000
000000000010110010110000000000000

No comments:

Post a Comment