Solved

Truncating mathematics result

Posted on 1997-12-10
4
279 Views
Last Modified: 2010-04-02
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
Comment
Question by:ieplved
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1256597
#include <math.h>
floor(a/b)

0
 
LVL 10

Accepted Solution

by:
rbr earned 50 total points
ID: 1256598
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
 
LVL 84

Expert Comment

by:ozo
ID: 1256599
(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
 

Author Comment

by:ieplved
ID: 1256600
rbr, are you familiar with Informix-4GL?

0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question