[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Truncating mathematics result

Posted on 1997-12-10
4
Medium Priority
?
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

Industry Leaders: 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!

Question has a verified solution.

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

656 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