Code tags for code please, they make the unreadable readable. [ code ] stuff [ /code ] without the extra spaces.
You get 'floating point error' when you divide by zero, check to see if things are getting parsed the way you expect.
You do not need to use fgetc to read in text data! Try scanf. Or better yet, sscanf. Read in data one line at a time then feed it through scanf to get what you want in one go.
You'll get purists complaining about scanf and its dangers but its far preferable to building your own integer-parsing routines. Used in this fashion it is fairly safe, with no risk of buffer overflows and none of the strange half-a-line-eaten problems plain scanf is infamous for.
Last edited by Corona688; 03-12-2009 at 12:25 AM..
Reason: adding more code
Does anyone have a simple way of doing floating point ("fp") division? For example, if I divide 3 by 5, I can get 0.6. The built-in calc (`bc`) will perform fp multiplication, but not division, at least not straight-up (i.e., starting bc and just typing in 3/5).
I am trying to do this using... (1 Reply)
hi, :)
I have a file like this
10.456
123.567
456.876
234.987
........
.......
What i want to do is ia have to add all those numbers and put the result in some other file.
Any help pls.
cheers
RRK (8 Replies)
Hello,
i have some variables say:
x=1.4
y=3.7
I wish to round off these values to :
x = 2 (after rounding off)
y = 4 (after rounding off)
I am stuck.
Please help. (7 Replies)
Hi,
see the simple code below
double i;
i=8080.9940;
printf(" val :%.30f\n",i);
output i m getting is
val :8080.993999999999700000000000000
when i m expecting
val :8080.9940
what happens?how can i avoid it?
thanks... (2 Replies)
Hi,
I am compiling "HelloWorld" C progam on 32-bit CentOS and i want to execute it on 64-bit CentOS architecture.
For that i copied the a.out file from 32-bit to 64-bit machine, but while executing a.out file on 64bit machine I am getting "Floating point exception error".
But we can run... (3 Replies)
Hi,
Could any one tell me how to compare to floating point no. using test command. As -eq option works on only intergers.
i=5.4
if
then
echo "equal"
else
echo "not equal"
fi
here output will be equal even though no. are unequal.
Thanks,
ravi (1 Reply)
is it not possible to simply di aritmetic without using bc or awk
i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant... (6 Replies)
Anyone help me i cant found the error of floating point
if needed, i added the code complete
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct
{
int hh;
int mm;
int ss;
char nom;
int punt;
}cancion;
typedef struct... (9 Replies)
I am writing a script in zsh shell, it fetchs a number from a file using the awk command, store it as a variable, which in my case is a small number 0.62000. I want to change this number by multiplying it by 1000 to become 620.0 using the command in the script
var2=$((var1*1000))
trouble is... (2 Replies)
Discussion started by: piynik
2 Replies
LEARN ABOUT HPUX
isgreaterequal
isgreaterequal(3M)isgreaterequal(3M)NAME
isgreaterequal() - floating-point quiet comparison macro (>=)
SYNOPSIS
floating-expr floating-expr
DESCRIPTION
The macro determines whether its first argument is greater than or equal to its second argument. The value of is always equal to however,
unlike does not raise the invalid exception when x and y are unordered.
The arguments must be of floating type. For HP Integrity servers, the arguments can be any floating type. For PA-RISC, each argument must
be either or
USAGE
To use the macro, compile either with the default option or with the and options. Make sure your program includes Link in the math library
by specifying on the compiler or linker command line.
RETURN VALUE
The macro returns the value of The macro raises no floating-point exceptions.
ERRORS
No errors are defined.
SEE ALSO isgreater(3M), isless(3M), islessequal(3M), islessgreater(3M), isunordered(3M), math(5).
STANDARDS CONFORMANCE isgreaterequal(3M)