Subject:
|
Converting a float to an integer
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Tue, 7 May 2002 12:13:41 GMT
|
Viewed:
|
2394 times
|
| |
| |
Hopefully this isnt a silly question. Does anyone know how to covert a float
to an integer? It doesn't appear that the function atoi exists.
Michael.
|
|
Message has 1 Reply: | | Re: Converting a float to an integer
|
| (...) float f = 1.4; int i = (int)((i >= 0) ? i + 0.5 : i - 0.5); OR if (f >= 0) i = (int)(i + 0.5); else i = (int)(i - 0.5); This is assuming you want to round to the nearest integer. Just curious, where are you getting the ascii strings that you (...) (23 years ago, 8-May-02, to lugnet.robotics.rcx.legos)
|
4 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|