Snippet. Vala. Rounding Double to IntThis is a small Vala function to round doubles to integers.
//======================== START OF FUNCTION ==========================//
// FUNCTION: round_double_to_int //
//=====================================================================//
int round_double_to_int(double dbl) {
(dbl > 0) ? (dbl += 0.5) : (dbl += (-0.5));
return (int)dbl;
}
//=====================================================================//
// FUNCTION: round_double_to_int //
//========================= END OF FUNCTION ===========================//
Updated on: 01 Dec 2025 |
|
|