[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] matematisk beregning i C hvor afrunding driller



Hej.
Jeg burde sikkert slet ikke blande mig på denne tid, men det forekommer
mig at være en noget mystisk beregning du laver. Den relative position
er jo bare (float)pos/255.0. Derfor mener jeg at beregningen bør være:

pos=(int)(((float)pos/255.0)*(float)len);

Du kan da godt bruge floor på den, men er det egentlig nødvendigt her?

M.v.h.
Søren


Kim Schulz wrote:
> 
> hejsa
> jeg har i ncurses gui'et til mit program en linje som skal symbolisere
> en placering af en kran.
> Linjens længde afhænger af terminalens størrelse, men er altid
> "Linjer-10". denne kalder jeg "len".
> Kranen har 255 positioner som den kan stå i. Disse skal vises på de
> "len" antal punkter.
> 0 og 255 er yderstillingerne.
> hvordan får jeg omregnet så de "len" antal positioner kan vise de 255
> positioner? .
> 
> len = L-10;
> parts= (255.0/(len));
> place = floorf(len-((int)(pos/parts)%(len));
> 
> Dette giver dog kun en fordeling mellem 0 og 235. hvorfor aner jeg ikke
> helt!
> 
> Any ideas?
> 
> MVH
> Kim


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *