Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

round decimal point in C

#include <math.h>

float val = 37.777779;

float rounded_down = floorf(val * 100) / 100;   /* Result: 37.77 */
float nearest = roundf(val * 100) / 100;  /* Result: 37.78 */
float rounded_up = ceilf(val * 100) / 100;      /* Result: 37.78 */
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #decimal #point #C
ADD COMMENT
Topic
Name
2+3 =