• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

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?
 
0
ieplved
Asked:
ieplved
  • 2
1 Solution
 
ozoCommented:
#include <math.h>
floor(a/b)

0
 
rbrCommented:
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:
(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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now