Snippet. Vala. Convert Double to Int

This snippet shows how to convert a double to int in Vala.

There are two ways to convert a double value to int:

1. Using the rint function from the Math package

int num = Math.rint(12.345);

2. Casting directly the double value to int:

int num = (int)12.345;

Result:

12

Updated on: 03 Dec 2024