+ Reply to Thread
Results 1 to 2 of 2

Thread: roundoff a floating point number to nearest integer

  1. #1
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321

    roundoff a floating point number to nearest integer

    Write function to roundoff a floating point number to nearest integer.

  2. #2
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321
    Code:
    int roundoff(float x)
    {
    	if (x >= 0) 
    		return (int)(x + 0.5);
    	else if (x < 0)
    		return (int)(x - 0.5);
    }

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 19th July 2010, 22:40
  2. Polygon and point
    By Surfer in forum Adobe
    Replies: 1
    Last Post: 22nd April 2010, 23:25
  3. Replies: 0
    Last Post: 22nd September 2009, 11:59

Tags for this Thread

Bookmarks

Posting Permissions

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