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 / 8620
8619  |  8621
Subject: 
Re: Interactive C
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Mon, 25 Feb 2002 17:14:33 GMT
Viewed: 
7305 times
  
You have to coerce the int to a float, e.g:

int i= 7;
float j= 3.;
float result;

result = j * (float)i;

The above should work.  Please let me know if not.

Fred



On Monday, February 25, 2002, at 11:26  AM, Brendan O'Hare wrote:

(Perhaps this isn't the right place to ask questions about I.C.
but it is
related to the handy board so I will continue)
I am trying to write a program that uses the lego sensors and
multiplies
them by constants that are floats. The expansion board returns
integers for
the lego sensors so I have a problem there as multiplying floats
and ints
isn't permitted by I.C. as far as I can make out. (the program
returns an
error saying that <float> * <int> isnt permitted)
Also when I calculate these values I want to use them to determine
how long
to leave motors on. I am turning the motors on full, leaving them
on using
the mseconds() function and then turning the motors off - again
using the
mseconds() function in order to create an exact force on my model. This
function requires long ints so I must convert my answers from
above which
are floats into long ints. Again my problem is that as far as I can see
there is no way of converting between these different variables.
Any ideas from anyone?
Thanks,Brendan




Message is in Reply To:
  Interactive C
 
(Perhaps this isn't the right place to ask questions about I.C. but it is related to the handy board so I will continue) I am trying to write a program that uses the lego sensors and multiplies them by constants that are floats. The expansion board (...) (23 years ago, 25-Feb-02, to lugnet.robotics.handyboard)

10 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