To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 2537
2536  |  2538
Subject: 
Converting a float to an integer
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 7 May 2002 12:13:41 GMT
Viewed: 
2255 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 (...) (22 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
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR