Re: [ats-lang-users] int_of_float?
Unleashing the potentials of types and templates
Status: Beta
Brought to you by:
ats-hwxi
From: Hongwei Xi <hw...@cs...> - 2010-04-11 10:34:13
|
On Sun, 11 Apr 2010, Rouan van Dalen wrote: >>Hi Hongwei >> >>Is there an int_of_float function in ATS? >> >>If so, do I need to include anything special to use it? >>If not, what would I need to do to convert a float value to an integer? Yes, there is one. It is in prelude/SATS/float.sats You can also do something as follows to implement such a function in C and then use it in ATS: %{^ static inline ats_int_type int_of_float (ats_float_type x) { return x ; } %} extern fun int_of_float (x: float): int = "int_of_float" Or you can introduce a casting function in ATS as follows: extern castfn int_of_float (x: float): int Cheers, --Hongwei Computer Science Department Boston University 111 Cummington Street Boston, MA 02215 Email: hw...@cs... Url: http://www.cs.bu.edu/~hwxi Tel: +1 617 358 2511 (office) Fax: +1 617 353 6457 (department) |