Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bash query

Status
Not open for further replies.

allywilson

Technical User
Nov 27, 2002
157
GB
Hi all,
I've just come across a bit of a strange anomaly in bash...

Essentially, I've been toying with the idea of random numbers (I understand that it's pretty much impossible for a true random, due to clock cycles, etc.) however I've just come across an inaccuracy (I think)...

So, I declare 3 variables. One is the time at that particular point when I declared it, the other is "pi". The 3rd variable adds the time variable to the pi variable - creating a 3rd number.

So, I echo out the 3rd variable. Looks fine. I then echo out the 3rd variable again but this time I remove columns 50 to 100 (I can't be bothered counting how many columns there is so settled on 100).

Now, the value changes, the time doesn't change (I don't redeclare it) and pi is obviously still the same...Why would the value change dependant on the number of columns being displayed. Below is the code I used to do this:

Code:
One=`date %H%M%S%N`
Two=`pi`
Three=`echo $One + $Two | bc`
echo $Three
	122555538787810.141592653589793238462643383279502[b]8841971693993751058\ 20974944592307816406286208998628034825342117067[/b]
echo $Three | colrm 50 100
	122555538787810.141592653589793238462643383279502[b]28034825342117067[/b]

The parts in bold is where the difference occurs.

And it does seem to react to the amount of columns being displayed. I changed it from 50 to 53, and there is yet again a difference...


Am I being thick here (I am pretty crap at maths to be honest)?

Cheers
 
Oh woe is me...I've figured it out. I was being dumb and removed column 50 to 100 but the value was obviously longer than 100...

Apologies for posting stupidly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top