11-01-2011
I think that's probably one of the most misunderstood things about floats. Using the equals operator on them is generally a bad idea. As Corona pointed out, you should test within a range of the value you want. The easiest way to do that is how he showed you, where, in his example the .001 would be the precision. The smaller that number (.000001 for example) the "closer" to your target you are. If you use, for example, .1, then you could be further from your target.
Of course, as with anything, this could still cause an issue. I mean, if you increase/decrease the value too much at each iteration you may miss your "window" of precision, never to return. So, you need to be aware and compare within an appropriate precision for the algorithm you're running.
10 More Discussions You Might Find Interesting
1. Programming
Hi my friends
I am beginner unix programmer I have written small c++ program in text editor and I have change it mode to 555 to make it executable file to use it in unix O.P.
#include<iostream.h>
main()
{
cout<<"Hello World";
}
but some syntax erroe came for <<
can any one help... (5 Replies)
Discussion started by: bintaleb
5 Replies
2. Linux
how can I compile and execute multifile program in unix os.:o (0 Replies)
Discussion started by: alokmishra8
0 Replies
3. UNIX for Dummies Questions & Answers
i am using unix os and my program is divided in two text files .:):)
how to compile and make one executable file, using unix command. (1 Reply)
Discussion started by: alokmishra8
1 Replies
4. Programming
Hi,
I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally.
If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Discussion started by: jiten_hegde
3 Replies
5. Solaris
Hi all:
I have a problem with a C++ service runing on solaris 10. This service only set a signal on oracle table. When the service detect a cut off on the line (tcp/ip), trigger a cobol program for set the signal OFF. When the line is on again, the service trigger the same cobol program for set... (0 Replies)
Discussion started by: hcastellani
0 Replies
6. Programming
I have made use of 'valgrind' and -finstrument-functions compiler option for debugging / analyzing code. Both the options lets us know the line / file being executed to some extent.
Is there a generic way that lets program dump the file:line it is getting executed dumped to a log file during... (3 Replies)
Discussion started by: uunniixx
3 Replies
7. Shell Programming and Scripting
I got a program named as "fastq_to_fasta".
I got a long list of file all named as AB1 and AB2.
My input file is :
071022_L1_AB1.fq
012121_L1_AB1.fq
021213_L1_AB1.fq
012153_L1_AB1.fq
071022_L1_AB2.fq
012121_L1_AB2.fq
021213_L1_AB2.fq
012153_L1_AB2.fq
.
.
.
.
.
.
My desired... (10 Replies)
Discussion started by: patrick87
10 Replies
8. Programming
How can I get around this? when my program reaches the following popen job it halts the program until the ping/netstat/ipconfig/traceroute is completed then resume to the rest of the program...
FILE *in;
extern FILE *popen();
char buff;
char newline;
char nstat;
char nping;
... (5 Replies)
Discussion started by: Jess83
5 Replies
9. Shell Programming and Scripting
I have a program dnapars
I execute the program from command line as following:
./dnapars
The program then prompts me some message as a user menu from where I have to select a series of options in the order R U Y R. And then I copy the output file (outfile) in another result file.
I wrote the... (3 Replies)
Discussion started by: deeptisjains
3 Replies
10. Shell Programming and Scripting
I need UNIX scripts for polling, Uncompressing files and moving files between directory. Also trying to save file paths and any other variables in an independent file (.env) and use these at runtime by executing this file in the main script. (3 Replies)
Discussion started by: new2script
3 Replies
LEARN ABOUT OPENDARWIN
atanf
FLOAT(3) BSD Library Functions Manual FLOAT(3)
NAME
float -- functions with single-precision floating-point arguments
DESCRIPTION
The following functions are available in single precision. The functions conform to the ISO/IEC 9899:1999(E) standard. They are similar to
the corresponding double-precision functions (which have the same name, without the "f" at the end). The double-precision functions have
their own pages. Wherever the double-precision functions use a double-precision floating-point value (as an argument or return value), these
functions use a single-precision floating-point value.
To use these functions you must add an additional flag to the link step that produces the executable binary. Specify "-lmx".
acosf()
acoshf()
asinf()
asinhf()
atanf()
atan2f()
atanhf()
cbrtf()
cosf()
coshf()
erff()
erfcf()
hypotf()
logf()
log2f()
log10f()
log1p()
powf()
sinf()
sinhf()
sqrtf()
tanf()
tanhf()
The following functions are also available in single precision. The functions conform to the ISO/IEC 9899:1999(E) standard. Each one has its
own page, which it shares with its corresponding double-precision function (which has the same name, without the "f" on the end). The page
can be found under both names.
You do not need to specify the "-lmx" flag to use these functions.
ceilf()
copysignf()
expf()
exp2f()
expm1f()
fabsf()
fdimf()
floorf()
fmaf()
fmaxf()
fminf()
fmodf()
frexpf()
ilogbf()
ldexpf()
lgammaf()
llrintf()
llroundf()
logbf()
lrintf()
lround()
modff()
nanf()
nextafterf()
remainderf()
remquof()
rintf()
roundf()
scalblnf()
scalbnf()
tgammaf()
truncf()
BSD
August 13, 2003 BSD