Hello,
I've had a look at the printf modifiers, but so far I haven't had much luck in making it do what I need.
I need to make it output with a set number of characters every time: whether it's by adding zeros at the end or by rounding, the output has to have the same number of characters in it, for example 6.
If it reads 10.1, 1, 0.1 and 0.01, the outputs would have to be 10.100 (the period counts), 1.0000, 0.1000 and 0.0100.
Is there a flag to do this?
You can specify the number of places after the decimal point, but not the number of digits in general.
What I'd do is print it to more decimal places than you need into a variable, then substr() the variable to get the number of characters you want.
Of course, that means you may end up with numbers like "10000." And if your number starts being so large the decimal point isn't included in the substr, the trick will no longer work.
Also: floating point numbers are not infinite-precision. If you look to enough decimal places you may find minute imprecision in the results of arithmetic.
I want to write/print a number through a shell script up to its last significant digit (LSD) after the decimal point.
Say,
x=10.00056000000000000
I want to print x as x=10.00056.
Note that x can be any thing so I cannot know the position of the LSD always.
Thanks. (16 Replies)
Hello experts,
I'm stuck with this script for three days now. Here's what i need.
I need to split a large delimited (,) file into 2 files based on the value present in the last field.
Samp: Something.csv
bca,adc,asdf,123,12C
bca,adc,asdf,123,13C
def,adc,asdf,123,12A
I need this split... (6 Replies)
I need help on arithmetic
root@server # hour=`date | awk {'print $4'} | cut -d: -f 1`; echo $hour
04
Now I subtract this result by 1 or 01 I get "3" as the answer. I need "03" as the answer, ie last two significant numbers should be there.
root@server # hour=`date | awk {'print $4'} | cut... (3 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:
As I stated in a previous thread, my assignment is to create a table of calculated data for the U.S. standard... (3 Replies)
Hello all.
I ran my AV app. and it scanned 600k+ files on my osx tiger powerpc laptop.
I went into terminal and ran ls -l */* on my applications folder.
for one entry it returned:
Snood3.0/:
total 17376
-rwxrwxrwx 1 ds admin 5152 Jan 17 2006 License30.txt
-rwxrwxrwx 1 ds ... (2 Replies)