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.
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)
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)
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)
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 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)
Hi,
Below is my input file:
Long list of significant figure
1.757E-4
7.51E-3
5.634E-5
.
.
.
Desired output file:
0.0001757
0.00751
0.00005634
.
.
. (10 Replies)
Discussion started by: perl_beginner
10 Replies
LEARN ABOUT REDHAT
ecvt
ECVT(3) Linux Programmer's Manual ECVT(3)NAME
ecvt, fcvt - convert a floating-point number to a string.
SYNOPSIS
#include <stdlib.h>
char *ecvt(double number, int ndigits, int *decpt, int *sign);
char *fcvt(double number, int ndigits, int *decpt, int *sign);
DESCRIPTION
The ecvt() function converts number to a null-terminated string of ndigits digits (where ndigits is reduced to an system-specific limit
determined by the precision of a double), and returns a pointer to the string. The high-order digit is nonzero, unless number is zero. The
low order digit is rounded. The string itself does not contain a decimal point; however, the position of the decimal point relative to the
start of the string is stored in *decpt. A negative value for *decpt means that the decimal point is to the left of the start of the
string. If the sign of number is negative, *sign is set to a non-zero value, otherwise it's set to 0. If number is zero, it is unspecified
whether *decpt is 0 or 1.
The fcvt() function is identical to ecvt(), except that ndigits specifies the number of digits after the decimal point.
RETURN VALUE
Both the ecvt() and fcvt() functions return a pointer to a static string containing the ASCII representation of number. The static string
is overwritten by each call to ecvt() or fcvt().
NOTES
These functions are obsolete. Instead, sprintf() is recommended. Linux libc4 and libc5 specified the type of ndigits as size_t. Not all
locales use a point as the radix character (`decimal point').
CONFORMING TO
SysVR2, XPG2
SEE ALSO ecvt_r(3), gcvt(3), qecvt(3), setlocale(3), sprintf(3)
1999-06-25 ECVT(3)