Solved

Truncating mathematics result

Posted on 1997-12-10
4
278 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to setup iphone app subscription service 3 119
C: GetDiskFreeSpaceEx() for default drive 14 104
How to get time_t value that is a week old 6 164
Read file descriptor 3 in C 14 104
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now