CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: using modf in C

  1. #1
    Join Date
    Mar 2004
    Posts
    41

    using modf in C

    Hi i hoping that someone could help me with a couple of lines of code for C
    I want it to do a devision but if the answer is a decimal then it rounds it up to the next integer eg: 23/3 = 8 thanks

  2. #2
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    Code:
    #include <math.h>
    
    .....
    int op1 = 23;
    int op2 = 3;
    
    // Always round up.
    int result = (int) ceil( (double)op1/ (double)op2);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured