TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Kurt Kuzba
date: 2004-04-04 05:28:20
subject: [C] way out ?

From: "Kurt Kuzba" 


From: Bob Stout
BS>  As you can see by how long it took me to respond, things have
BS>  been busy.  The project I've been working on since early last
BS>  year is starting field trials on a real well next week, so
BS>  I've been pretty much buried in last minute adjustments and
BS>  documentation for the past month. I just finished the 120 page
BS>  detailed design/implementation spec yesterday. My partner on
BS>  the project is taking the spec with him to the field for
BS>  further revisions, so I have a week of lower-intensity stuff
BS>  to do, hence my return here.

    Hmmm...  I am singularly unconvinced that I can accept this as
 a proper excuse.  However, since I can not wield a whip at this
 distance, I suppose I will have to just allow it.  Did you take a
 look at the step-up module I did.  It popped out all by itself.
 I noted that Excel has a rounded step-up function a bit earlier,
 and wondered briefly how they accomplished it, and consigned it
 to the depths of unconsciousness thereafter.  When the question
 came up, an answer just popped up from out of the soup.  Neat.
 There is no problem so complex that a nap can't help.  

/*_|_|  stepup.c  PUBLIC DOMAIN by Kurt Kuzba - (02/15/2004)
_|_|_|  C code module to round up to a stepped integer value. _|_|_|  Code
is supplied AS IS.  No warrantees or guarantees _|_|_|  are given or
implied as to usability or appropriateness. _|_|*/

#include 
float stepup( float num, int step)
{
    long rounded = (long)num;
    if(((float)rounded < num) || (0 != (rounded % step)))
        rounded += (step - (rounded % step));
    return (float) rounded;
}
int main(void)
{
    printf("70.0000 stepup 5 = %.2f\n", stepup(70.0000, 5));
    printf("70.0001 stepup 5 = %.2f\n", stepup(70.0001, 5));
    printf("71.0000 stepup 5 = %.2f\n", stepup(71.0000, 5));
    printf("73.0000 stepup 5 = %.2f\n", stepup(73.0000, 5));
    printf("74.9999 stepup 5 = %.2f\n", stepup(74.9999, 5));
    return 0;
}

/*_|_|  end stepup.c
_|_|*/

>  kkuzba{at}centurytel.net   http://home.centurytel.net/kkuzba
>  The Master does his job and then stops.  (Tao te Ching #30)

--- BBBS/LiI v4.01 Flag-5
* Origin: Prism's_Point (1:261/38.1)
SEEN-BY: 633/267 270
@PATH: 261/38 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.