11-13-2003
awk uses double precision floating point. There is a limit to its accuracy and your data exceeds that limit.
10 More Discussions You Might Find Interesting
1. Programming
hello everybody,
here is my problem:
________________________________________
#include <stdio.h>
int main()
{
int i=10;
printf("value is %i",i);
return 0;
}
_________________________________________
when i compile and execute, nothing appears on screen!!
but if i replace the printf... (2 Replies)
Discussion started by: brain_processin
2 Replies
2. Shell Programming and Scripting
hi all,
im having a problem with using perl printf. my requirement is to print a string (like ) at the right most end of the screen.
i tried this perl script, but it fails with an error;
#!/usr/bin/perl
use strict;
use warnings;
my $scrW = 0;
my $str = `stty size`; # get the... (5 Replies)
Discussion started by: wolwy_pete
5 Replies
3. Shell Programming and Scripting
I have the following code:
$ awk '{ printf "%-10s %s\n", $1, $2, $3, $4, $5, $5, $6 }' file
i can only print the first 2 elements ($1,$2). How can i print all the elements to appear like this:
aardvark 5555553 jhfjhfjkg efiigig ejkfjkej wjkdjk
alpo-net 5553412 ... (2 Replies)
Discussion started by: DDoS
2 Replies
4. Shell Programming and Scripting
Hi,
I've got a basic problem using printf statement in awk.
I want to write float values with always 8 characters width.
Examples :
1.345678
12.45678
123.4567
1234.678
-23.5678
-2.45678
-23456.8
.....
I cannot find the right printf format %8.1f, %7.5f....
Can anyone help ?... (4 Replies)
Discussion started by: cazhot
4 Replies
5. Shell Programming and Scripting
echo $bbsize
1.5
echo $fillpercent
.95
echo $bbsize | awk '{printf "%.2f\n",$0*$fillpercent}'
2.25
echo $bbsize | awk '{printf "%.2f\n",$0*.95}'
1.42
1.42 is what I'm expecting...
echo $blocksize
4096
echo $bbsize | awk '{printf "%.2f\n",$0*$blocksize}'
2.25
echo $bbsize |... (3 Replies)
Discussion started by: xgringo
3 Replies
6. Shell Programming and Scripting
Hi Friends,
Scripting newb here. So I'm trying to create a geektool script that uses awk and printf to output certain fields from top (namely command, cpu%, rsize, pid and time, in that order). After much trial and error, I've pretty much succeeded, with one exception. Any process whose name... (3 Replies)
Discussion started by: thom.mattson
3 Replies
7. Shell Programming and Scripting
I am having a major problem with printf, The more I pad it, the less I see :(
The problem is in the first function, report
Am I ruining output somewhere? I wont print out the names propely, it cuts them off or deletes them completely :(
#!/bin/bash
report()
{
printf "%-10s" STUD# ... (2 Replies)
Discussion started by: L0ckz0r
2 Replies
8. Shell Programming and Scripting
In one of the scripts I am using pintf function as following
printf "%s%s%s\n" "$f1" "$f2" "$f3"
f3 variable contains a string of 10 characters. However it has value first 7 character and last 3 characters are empty.
Example
Aaaaaaa<3 spaces>
bbbbbbb<3 spaces>
ccccccc<3 spaces>... (4 Replies)
Discussion started by: varunrbs
4 Replies
9. Shell Programming and Scripting
Hi,
I am using the following code to assign a count value to a variable. But I get nothing. Do you see anything wrong here.
I am new to all this.
$CTR=`remsh $m -l $MACHINES{$m} -n cat $output | grep -v sent | grep \"$input\" | sort -u | awk '{print $5}'`;
Upto sort - u it's... (2 Replies)
Discussion started by: nurani
2 Replies
10. Shell Programming and Scripting
i have written small script as follows:
name="hi hello"
printf "%-20s" $name
This gives me strange output. -20s format is applied on both word of string. i.e it displays both word hi and hello in space of 20 length.
I want to display entire string "hi hello" in length of 20 space.
plz... (2 Replies)
Discussion started by: admc123
2 Replies
exp(3m) exp(3m)
Name
exp, expm1, log, log10, log1p, pow - exponential, logarithm, power
Syntax
#include <math.h>
double exp(x)
double x;
float fexp(x)
float x;
double expm1(x)
double x;
float fexpm1(x)
float x;
double log(x)
double x;
float flog(x)
float x;
double log10(x)
double x;
float flog10(x)
float x;
double log1p(x)
double x;
float flog1p(x)
float x;
double pow(x,y)
double x,y;
Description
The and functions return the exponential function of x for double and float data types, respectively.
The and functions return exp(x-1 accurately, including tiny x for double and float data types, respectively.
The and functions return the natural logarithm of x for double and float data types, respectively.
The and functions return the logarithm of x to base 10 for double and float data types, respectively.
The and functions return log(1+x) accurately, including tiny x for double and float data types, respectively.
The function returns x**y.
Error (due to roundoff)
The and functions are accurate to within an ulp, and is accurate to within approximately 2 ulps; an ulp is one Unit in the Last Place.
The function is accurate to within 2 ulps when its magnitude is moderate, but becomes less accurate as the result approaches the overflow
or underflow thresholds. Theoretically, as these thresholds are approached, almost as many bits could be lost from the result as are indi-
cated in the exponent field of the floating-point format for the resultant number. In other words, up to 11 bits for an IEEE 754 double-
precision floating-point number. However, testing has never verified loss of precision as drastic as 11 bits. The worst cases have shown
accuracy of results to within 300 ulps for IEEE 754 double-precision floating-point numbers. In general, a (integer, integer) result is
exact until it is larger than 2**53 (for IEEE 754 double-precision floating-point).
Return Values
All of the double precision functions return NaN if x or y is NaN.
The function returns HUGE_VAL when the correct value would overflow, and zero when the correct value would underflow.
The and functions return NaN when x is less than or equal to zero or when the correct value would overflow.
The function returns NaN if x or y is NaN. When both x and y are zero, 1.0 is returned. When x is negative and y is not an integer, NaN
is returned. If x is zero and y is negative, -HUGE_VAL is returned.
The function returns NaN when x is negative.
See Also
math(3m)
RISC exp(3m)