Search code examples
gtkvala

Vala: Convert int to uint16


How do I convert from int to uint16 in vala?

My requirement is to convert the text in decimal in a gtkEntry to uint16.

How do I do this?


Solution

  • Just cast. uint16 as_uint16 = (uint16) as_int;

    You may want to first check that the value is between uint16.MIN and uint16.MAX.