# rounding of number using C programming language

Page 1 of 1

## 2 Replies - 7846 Views - Last Post: 28 January 2009 - 05:58 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=83240&amp;s=6f1bd62fdaeb08d682db2c10123b6f01&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 frenz

Reputation: 0
• Posts: 1
• Joined: 28-January 09

# rounding of number using C programming language

Posted 28 January 2009 - 03:33 AM

hi good day ..may i ask how can you make a program that can round numbers with decimal points using C programming codes. Rounding it in any decimal places ...
Is This A Good Question/Topic? 0

## Replies To: rounding of number using C programming language

### #2 tommod

Reputation: 8
• Posts: 32
• Joined: 21-July 08

## Re: rounding of number using C programming language

Posted 28 January 2009 - 04:36 AM

You should have a look at the setprecision manipulator in C++.

t

### #3 baavgai

• Dreaming Coder

Reputation: 7361
• Posts: 15,285
• Joined: 16-October 07

## Re: rounding of number using C programming language

Posted 28 January 2009 - 05:58 AM

Depends on if you want to round the value or the display of the value.

For display, in C, printf has a format of decimal precision.

For value, there are some rounding functions. To roll you own, just multiply the number by 10 to the power of digits you want, at 0.5 for rounding, drop the decimal part (cast int), and divide it by the same amount you multiplied by.

This post has been edited by baavgai: 28 January 2009 - 05:58 AM