User Tools

Site Tools


user:vcordes1:portfolio:con

Purpose

  • To create a number system converter that will process ridiculous numbers via bash

Procedure and Necessary Knowledge

  • Scripting and debugging

Miscellaneous

  • This will only work up to base 10
  • I don't remember how many digits or what number it will properly process…it is however a lot

The Script

#!/bin/bash

a=0
echo -n "please enter a base: "
read base
echo -n "please enter a number: "
read number
until [ $number -eq 0 ]; do
	n=0
	until [ `echo "$number-$base^$n" | bc` -lt 0 ]; do
		let n=$n+1
	done
	let n=$n-1
	let number=$number-`echo "$base^$n" | bc`
	places=""
	for((i=0;i<$n;i++)); do
		places="${places}0"
	done
	places="1${places}"
		a=`echo "$a+$places" | bc`
done
echo "The value in base $base is: $a"
exit 0

Attributes

  • Scripting
  • Commands
  • The UNIX Shell
  • The UNIX development environment
  • Text Processing
user/vcordes1/portfolio/con.txt · Last modified: 2011/12/15 17:35 by vcordes1