To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 4449
4448  |  4450
Subject: 
Re: IC Programming.
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Wed, 30 Sep 1998 15:27:14 GMT
Original-From: 
Will <willbain@csSPAMCAKE.umt.edu>
Reply-To: 
WILLBAIN@CS.UMTnospam.EDU
Viewed: 
836 times
  
Keith - Lui wrote:
Does anyone know how to convert floating point variables to integers in IC?

Converting between types is called casting, and it goes like this:

    float f = 4.6;
    int i = (int) f;     /* should assign 4 to i, I think */
    f = (float) i;       /* ought to assign 4.0 to f */

I'm not certain, but usually casting a float to an integer truncates
(rounds down).  A simple experiment would determine whether I'm
remembering this correctly.  Good luck!

--Will
                                          , ,
        __@_/             \_@__           |/
          |                /__,           o             @_/
          )\              )              ( \            (\/\\,
~~~~~~~~~ ' ` ~~~~~~~~~~~ ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wendy Parson,                        If the world were a logical place,
Will Bain,                                   men would ride sidesaddle.
& Tatoosh                                              --Rita Mae Brown



Message is in Reply To:
  IC Programming.
 
Hi all, Does anyone know how to convert floating point variables to integers in IC? I want to use the control the motor using an algorithm. However, that algorithm always return a floating point number, and motor(m,p) can only use integer p. Keith (26 years ago, 29-Sep-98, to lugnet.robotics.handyboard)

2 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