floor() and ceiling()

This is a discussion on floor() and ceiling() within the C++ Programming forums, part of the General Programming Boards category; doesn't floor round a decimal number down to the nearest whole number, and ceiling to go up?...

  1. #1
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552

    floor() and ceiling()

    doesn't floor round a decimal number down to the nearest whole number, and ceiling to go up?

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Yes that is what they do. You can write your own macro's for these and gain a little speed.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: floor() and ceiling()

    Originally posted by frenchfry164
    I am making a kickass RPG called Terminus. I will make a website soon. (0.00000001% done, lol)
    Better take a peek at Google so you can guage your chances of getting your ass sued off...

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    this is just a project name. it isn't the real name. plus I'm not making any money off it (freeware), so they can't sue me unless I say it's an original name, or something like that.

    and on the rounding issue, how can a round a number to the nearest 40th number up? Like if I had 56 it would round it up to 80, etc.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    int roundto( int rndto, int tornd )
    {
        return ( tornd<(rndto/2) ? 0 : rndto );
    }
    That should work.

    number = 37;
    number = roundto( 80, 37 );

    Now number is rounded down to zero.

    number = 40;
    number = roundto( 80, 40 );

    Now number is rounded up to 80.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21