The POSIX standards for awk specify that it must behave as if it uses (at least) double precision floating point values as defined by the C Standard. When ptr points to a string starting with a case insensitive "infinity", "inf", or "NaN", the C standard requires strtod(ptr, endptr) to set endptr to point to the character after the last character matched from one of those three strings and return the double precision floating point format representation for an infinity, infinity, or Not A Number, respectively, on systems that also support the IEEE 754 floating point standard.
So, yes, POSIX requires what was reported on HP/UX and Solaris systems. (Note, however, that the POSIX conforming version of awk on Solaris systems is /usr/xpg4/bin/awk; not nawk.) I'm not sure where the "Q" in NaNQ reported on AIX is coming from. The gawk output shown on Windows appears to be non-conforming.
And, for the record, on OS X Yosemite 10.10.3, the output from those three commands is, respectively:
These 4 Users Gave Thanks to Don Cragun For This Post:
i'm new to shell scripting and have a problem please help me
in the script i have a nawk block which has a variable count
nawk{
.
.
.
count=count+1
print count
}
now i want to access the value of the count variable outside the awk block,like..
s=`expr count / m`
(m is... (5 Replies)
i'm puzzled....
trying to look for the pattern }"'. but the below code returns to me the message below (pattern is curley queue + dbl qt + sng qt + period)
nawk -v pat="\}\"\'\."'
{
if (match($0, pat)) {
before = substr($0,1,RSTART-1);
... (11 Replies)
Howdy experts,
We have some ranges of number which belongs to particual group as below.
GroupNo StartRange EndRange
Group0125 935300 935399
Group2006 935400 935476
937430 937459
Group0324 935477 935549
... (6 Replies)
Hello All,
I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns.
I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions.
If I... (11 Replies)
I need some help in generating pair of numbers in orders using FORTRAN code.
The order is like following.
loop_1: 1,2 2,3 3,4 4,5 5,6 6,7 7,8 ..... until <= 2000
loop_2: 1,3 3,5, 5,7 7,9 9,11 11,13 ........until <= 2000
loop_3: 1,4, 4,7 7,10 10,13 13,17 ..... until... (3 Replies)
Hi All,
This might be a basic question... I need to write a script to find all/any Speacial/Null/Control Chars and Print Line Numbers from an input file.
Output something like
Null Characters in File Name at : Line Numbers
Line = Print the line
Control Characters in File Name at : Line... (2 Replies)
Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare
nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
Hi All,
I want to keep the name of the songs with their respective extensions only.
Sample Code
========
03 Choti choti gaiya choti choti gaval.mp3
03---Brazil Dhol.mp3
03 PAYALIYA .mp3
04 - Isq Risk .mp3
04%20-%20Oh%20My%20Love(wapking.in).mp3
08 - A2 - Aasan Nahin Yahan .mp3
AE... (3 Replies)
I sux at this type of stuff. I have a huge wordlist. I want to get rid of everything in each word except the letters. I want to remove numbers and all special characters. And since this list was created using cewl I some how picked up something like so Latin characters and would like to remove them... (6 Replies)
Discussion started by: sub terra
6 Replies
LEARN ABOUT OSF1
strtof
atof(3) Library Functions Manual atof(3)NAME
atof, strtod, strtof, strtold - Converts a character string to a double-precision floating-point value
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdlib.h>
double atof(
const char *nptr);
double strtod(
const char *nptr,
char **endptr);
float strtof(
const char *nptr,
char **endptr);
long double strtold(
const char *nptr,
char **endptr);
PARAMETERS
Points to the character string to convert. Specifies either a null value, a pointer to the character that ended the scan, or a pointer to
a null value.
DESCRIPTION
The atof() function converts, to a double floating-point value, the string pointed to by the nptr parameter - up to the first character
that is inconsistent with the format of a floating-point number. Leading space characters are ignored. A call to this function is equiva-
lent to a call to strtod(nptr, (char **) NULL), except for error handling. When the value cannot be represented, the result is undefined.
The strtod(), strtof(), and strtold() functions convert the initial portion of the string pointed to by the nptr parameter to double,
float, and long double representation, respectively. First, the input string is decomposed into the following three parts: An initial,
possibly empty, sequence of space characters (as specified by the isspace() function). A subject sequence interpreted as a floating-point
constant. A final string of one or more unrecognized characters, including the terminating null character of the input string.
After decomposition of the string, the subject sequence is converted to a floating-point number and the resulting value is returned. A
subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-space character, that is of
the expected form. The expected form and order of the subject sequence is: An optional plus (+) or minus (-) sign. A sequence of digits
optionally containing a radix character. An optional exponent part. An exponent part consists of e or E, followed by an optional sign,
which is followed by one or more decimal digits.
The subject sequence contains no characters when the input string is empty or consists entirely of space characters, or when the first non-
space character is other than a sign, a digit, or a radix character.
For the strtod(), strtof(), and strtold() functions, when the value of the endptr parameter is not (char**) NULL, a pointer to the charac-
ter that terminated the scan is stored at *endptr.
When a floating-point value cannot be formed, *endptr is set to nptr.
The strings NaN ("not a number"), Inf, and Infinity (the case of the characters does not matter) are recognized as valid only when the pro-
gram is compiled with the -ieee option.
NOTES
The setlocale() function may affect the radix character used in the conversion result. Full use
RETURN VALUES
When the string is empty or begins with an unrecognized character, +0.0 is returned as the floating-point value.
If the calling routine is compiled with IEEE floating point enabled (-ieee flag), errno will be set to ERANGE if the conversion underflows
to zero. Similarly, if the value overflows, ERANGE will be set and a properly signed infinity will be returned.
If the calling routine is not compiled with IEEE floating point enabled, any underflow will cause errno to be set to ERANGE and a properly
signed zero to be returned. An overflow will cause errno to be set to ERANGE and will return a properly signed DBL_MAX, FLOAT_MAX, or
LDBL_MAX.
Upon successful completion, all of the functions return the converted floating-point value.
ERRORS
If the atof(), strtod(), strtof(), or strtold() function fails, errno may be set to the following value: The input string is out of range
(that is, the subject sequence cannot be converted to a floating-point value without causing underflow or overflow).
RELATED INFORMATION
Functions: atoi(3), scanf(3) delim off
atof(3)