12-15-2003
Due to the way floating point numbers are represented internally (e.g. IEEE754 standard), they can never be stored in the exact manner. They are stored in the form of an exponent and a mantissa and together they spell out what the number is. However, unlike integral arithmetic, this representation is not exact and is subject to errors when you are trying to compare a floating pt number from another. In daily arithmetic both 32.2-29.2 and 3.0 should be identical, but they are derived in a different manner internally and can arrive at a slightly different internal representation, so the comparison fails due to round-up errors.
I forgot which perl FAQ number it is, but I'm pretty sure there is an FAQ entry that suggests how you should implement floating-pt number comparison. Please try to dig it out yourself.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I have thousands of files in a directory that have the following 2 formats:
289620178.aln
289620179.aln
289620180.aln
289620183.aln
289620184.aln
289620185.aln
289620186.aln
289620187.aln
289620188.aln
289620189.aln
289620190.aln
289620192.aln....
and:
alnCDS_1.fasta (1 Reply)
Discussion started by: greptastic
1 Replies
2. UNIX for Advanced & Expert Users
Hi,
The task i have to do is to
1- create a database contains the Names .run the query and store results in hash make the Name field is the hash key
2- in the same time i have a txt which i will loop through it word by word and check for each word if a hash key ( compare it with the Names in... (0 Replies)
Discussion started by: eng_shimaa
0 Replies
3. Shell Programming and Scripting
Hi Perl Gurus , need URGENT HELP PLEASE !!!!!
I have one recursive Perl function which takes path of any directory as argument and returns array containing all the sub folders inside it recursively.
Now the problem is that it works well if i use it with one time but the problem is that when... (0 Replies)
Discussion started by: anthriksh2000
0 Replies
4. Shell Programming and Scripting
I am facing a problem in replacing the file contents by iterating through the list.
My present code:
Code:
#!/bin/bash#
TFILE="/tmp/vinay/testb_1.txt"
while read linedo
aline="$line"
echo $aline
code=`echo $aline|cut -d ',' -f1`
country=`echo $aline|cut -d... (5 Replies)
Discussion started by: av_vinay
5 Replies
5. Programming
Hello All,
Im a Hardware engineer, I have written this script to automate my job. I got stuck in the following location.
CODE:
..
..
...
foreach $key(keys %arr_hash) {
my ($loc,$ind,$add) = split /,/, $arr_hash{$key};
&create_verilog($key, $loc, $ind ,$add);
}
sub create_verilog{... (2 Replies)
Discussion started by: riyasnr007
2 Replies
6. Shell Programming and Scripting
hi all,
i am writing a ksh script, i am logging into an oracle db via sqlplus and running a select statement but i dont know how i can store the results from the sql so i can iterate over it and do more operations over it. I dont want to write a stored procedure with a cursor since i need to... (2 Replies)
Discussion started by: cesarNZ
2 Replies
7. Shell Programming and Scripting
Hi,
I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all .
my %result (
$abc => {
'data_count' => '10',
'ID' => 'ABC122',
}
$def => {
'data_count' => '20',
'ID' => 'defASe',
... (1 Reply)
Discussion started by: asak
1 Replies
8. Shell Programming and Scripting
I am trying to speed up creating a line by line hash file from a huge file using Perl.
Here is my current (working but too slow) Bash code:
(while read line; do hash=$(echo -n $line | md5sum); echo ${hash:0:32}; done)And here is my Perl code:
perl -MDigest::MD5 -le 'foreach $line ( <STDIN> )... (3 Replies)
Discussion started by: Michael Stora
3 Replies
9. Shell Programming and Scripting
Experts - Any advice on how to get a hash value in a foreach loop?
Values print correctly on standalone print statements, but I can't access value
in foreach loop.
See sample code below and thanks in advance.
foreach my $z (sort keys %hash) {
for $y (@{$hash{$z}}) {
print "$z... (6 Replies)
Discussion started by: timj123
6 Replies
ilogb(3M) ilogb(3M)
NAME
ilogb(), ilogbf(), ilogbl(), ilogbw(), ilogbq() - radix-independent exponent functions
SYNOPSIS
Integrity Server Only
DESCRIPTION
The function computes the exponent of the floating point value x. Formally, the return value is the integral part of log base r of |x| as
a signed integral value, for nonzero x, where r is the radix of the machine's floating-point arithmetic. The radix r is 2 on HP-UX sys-
tems.
If x is denormal it is treated as though it were normalized before the exponent is determined.
Note: is equivalent to for all values of x
Integrity Servers Only
is a version of it takes a argument.
is a version of it takes a argument.
is an version of it takes an argument.
is equivalent to on HP-UX systems.
USAGE
To use these functions, compile either with the default option or with the and options.
To use (for Integrity servers) or compile also with the option.
Make sure your program includes Link in the math library by specifying on the compiler or linker command line.
For more information, see the at the following site:
RETURN VALUE
If x is NaN, returns
If x returns
If x is zero, returns
Integrity Servers Only
If x is NaN, +-INFINITY, or zero, then the invalid floating-point exception is raised (as specified by C99 TC2)
The macros and are defined in
ERRORS
No errors are defined.
SEE ALSO
frexp(3M), logb(3M), scalb(3M), scalbn(3M), scalbln(3M), math(5).
STANDARDS CONFORMANCE
: XPG4.2, ISO/IEC C99 (including Annex F, "IEC 60559 floating-point arithmetic")
: ISO/IEC C99 (including Annex F, "IEC 60559 floating-point arithmetic")
ilogb(3M)