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 / 7070
  mixing variable types in IC
 
Hi John- You can convert quantities from one data type to another (it's called "casting", I believe). The following computes the quantity x/y, then converts it to a float: ---...--- int x, y; float c; float divide ( int x, int y) { c = (float) (...) (25 years ago, 14-Nov-99, to lugnet.robotics.handyboard)
 
  Re: mixing variable types in IC
 
[Ben Davis] spake unto the ether: (...) Hmm, I think you want c = ((float)(x))/((float)(y)); Otherwise, the division will be done first as integers, giving an integer quotient, which you're then turning into a float. *Rich* (25 years ago, 14-Nov-99, to lugnet.robotics.handyboard)

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