hi everyone,
i want to convert a floating number to integer number without make any approximation ex:-
double x = 2.6;
int y = Convert.ToInt16(x) ; // output y= 3
all i need that make y= 2
i used this conversion in c++ vs6 the output with me is 2 please help me reach this output
many thanx
Loading
Kirtan PatelPosted Nov 3, 2009, 5:13 AM
if mys solution helps you then Check "Do you like this answer" check Box please :)
double x = 2.999;
int y = Convert.ToInt16(Math.Truncate(x));
Mohammed GamalPosted Nov 3, 2009, 6:37 AM
Mohammed GamalPosted Nov 3, 2009, 6:36 AM
Nilanka DharmadasaPosted Nov 3, 2009, 5:38 AM
Use this.