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 / 5574
5573  |  5575
Subject: 
Re: Type conversion.
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Fri, 19 Feb 1999 23:37:03 GMT
Original-From: 
Duncan Orthner <orthner@idirect(NoSpam).com>
Viewed: 
1082 times
  
At 10:25 PM 2/19/99 +0100, you wrote:

My answere are , how can i convert a integer number to a floating point
number?

Hi, what you want to do is called type casting,ie. you must explicitly
specify the type. I've included some sample code that uses it. Because the
beeper function expects a float but the knob function returns an integer,
you have to modify the value to a float.

ie.
/*
    adjusts the frequency of the buzzer with the knob
*/

void main()
{
float h=0.0;
while(1){
printf("Press start to  adjust pitch...\n");
start_press();
printf("Stop to quit\n");
   while(1) {
         h=(20.0*(float) knob());                   <--see here
         if (h<20.0){
               h=20.0;
               }
         set_beeper_pitch(h);
         beeper_on();
         if (stop_button()) {
            beep();
            break;
         }
   }
}
}

Hope this helps, Duncan



Message is in Reply To:
  Type conversion.
 
Hi to all. I'm not very practice with IC. My answere are , how can i convert a integer number to a floating point number? I want to make a moltiplication between an intger number and a floating. I make this: int temp; float dtemp; dtemp=temp*3.5; (...) (26 years ago, 19-Feb-99, to lugnet.robotics.handyboard)

5 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