• C

Truncating mathematics result

I would like to truncate the result of division , without rounding up,
for report presentation.

Is there such a feature in C and Informix?
 
ieplvedAsked:
Who is Participating?
 
rbrConnect With a Mentor Commented:
If the result is in the range of a long int you can use

long ip;
double a=10.0,b=7.2;
ip= (long)(a/b);

otherwise use the floor command.
0
 
ozoCommented:
#include <math.h>
floor(a/b)

0
 
ozoCommented:
(long)(a/b) can also round up if a/b is negative, which ieplved didn't want.
(On the other hand, the question also said "truncate",
so it's not quite clear what's really being asked for)
0
 
ieplvedAuthor Commented:
rbr, are you familiar with Informix-4GL?

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.