Feb 20, 2003 #1 cnjihia Technical User Feb 18, 2003 4 KE Hi What are the C++ equivalents for the ord and round functions in delphi?What header file do I need to access them?
Hi What are the C++ equivalents for the ord and round functions in delphi?What header file do I need to access them?
Feb 21, 2003 #2 xwb Programmer Jul 11, 2002 6,828 GB Not sure about round. There is ceil and floor which will give you the greatest integer less than and the smallest integer more than. For ord, just cast it. For instance int x = 48; char c = (char) x; or char c = char(x); To go in the opposite direction, char c = 'A'; int x = (int) c; or int x = int(c); Upvote 0 Downvote
Not sure about round. There is ceil and floor which will give you the greatest integer less than and the smallest integer more than. For ord, just cast it. For instance int x = 48; char c = (char) x; or char c = char(x); To go in the opposite direction, char c = 'A'; int x = (int) c; or int x = int(c);
Feb 26, 2003 #3 Leibnitz Programmer Apr 6, 2001 393 CA Take a look at thread207-476940 Upvote 0 Downvote
May 1, 2003 #4 Supernat03 Programmer Apr 30, 2003 206 US Quick rounding routine that will fix the floating point flaw when trying to display a value on a form. double To_Int(double Value) { double Lower, Upper, LDiff, UDiff, NewVal; long int TempVal; double ReturnVal; NewVal = Value*10000; Lower = floor(NewVal); Upper = ceil(NewVal); LDiff = NewVal - Lower; UDiff = Upper - NewVal; if (LDiff < UDiff) TempVal = (long int) Lower; else TempVal = (long int) Upper; ReturnVal = (double) TempVal/10000; return ReturnVal; // Extend 4 decimal places } Upvote 0 Downvote
Quick rounding routine that will fix the floating point flaw when trying to display a value on a form. double To_Int(double Value) { double Lower, Upper, LDiff, UDiff, NewVal; long int TempVal; double ReturnVal; NewVal = Value*10000; Lower = floor(NewVal); Upper = ceil(NewVal); LDiff = NewVal - Lower; UDiff = Upper - NewVal; if (LDiff < UDiff) TempVal = (long int) Lower; else TempVal = (long int) Upper; ReturnVal = (double) TempVal/10000; return ReturnVal; // Extend 4 decimal places }