[SOLVED] Converting double to integer using fint() is not working. Is there any alternative for this?

Issue

This Content is from Stack Overflow. Question asked by Nitish Yadav

I want to convert 1.8 to 2.0 and then change the type of the result to an integer value i.e., 2. To do this, I execute the following function for the shown template.

int xx;
double dx=round(1.8);
void cast() { xx = fint(dx); }

enter image description here

Upon execution, the value of xx is still 0. Could someone please help me figure this out.



Solution

Floating point operations are supported only in SMC queries.

Please try the following query:

simulate [<=100] {xx, dx} 


This Question was asked in StackOverflow by Nitish Yadav and Answered by mariusm It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?