Results 1 to 7 of 7

Thread: [RESOLVED] Maths question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Resolved [RESOLVED] Maths question

    Hi guys,

    I was wondering whether this was possible in C++?

    I have an integer that i was to divide by 25, but i only want the number of times the 'full' 25 can fit into the integer i have.

    For example if the integer i have is 51, it will return 2.

    I hope this makes sense.

    Thanks in advance for any help.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Maths question

    As long as the variable that will hold the result is an integer, it simply "cut off" the decimals after the division:
    vb Code:
    1. int x = 51;
    2.     int y = 25;
    3.     int z = x / y;
    z will contain 2.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: Maths question

    Ok kool. Thanks. Will it not round the number up or down???

    Thanks again.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Maths question

    Quote Originally Posted by Kimmy4
    Ok kool. Thanks. Will it not round the number up or down???

    Thanks again.
    It wont round, it will simply (I've lost the word for it) "cut off" the decimals.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: Maths question

    Ok kool, i'll have to try and remember that for next time.
    Thanks again.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Maths question

    Quote Originally Posted by Atheist
    It wont round, it will simply (I've lost the word for it) "cut off" the decimals.
    Truncate I believe would be the word you're looking for.

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Maths question

    Quote Originally Posted by kfcSmitty
    Truncate I believe would be the word you're looking for.
    Thank you thats the word
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

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