Thread: Meet some problem in C++ programming

  1. #16
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    segmentation fault
    Quote Originally Posted by Ngoo Jia Xun View Post
    Use ceil and float to round up?
    Where "cents" is the monetary value and x is an integer divisor. If x is a float, you do not need to cast it to a double. Otherwise, both those casts are necessary -- and, nb, do not do this:

    Quote Originally Posted by nonoob View Post
    This does not sound like a cumulative rounding error but instead the programmer elected to use floating point constant when there was no use of floating point warranted. An integer divide-by-10 would do the job. And I bet those Patriot Missile programmers get paid more than I do.
    Implying somebody (perhaps) got thru school without having this point brought home properly. Hopefully we saved some lives here today .

    I always feel overzealous about this one, lol (thanks CornedBee & mike65535).
    Last edited by MK27; 06-14-2011 at 09:21 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #17
    Registered User
    Join Date
    Jun 2011
    	adjustedAmount = lround((double)amountPayable/(double)amountPayable);
    Like this? Sorry, still newbie in C..

  3. #18
    Join Date
    Aug 2010
    Ontario Canada
    Quote Originally Posted by nonoob View Post
    And I bet those Patriot Missile programmers get paid more than I do.
    I'd say that's a safe bet... Consdering that an army Private earns more than most Programmers (in Canada, at least).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem - 2 elevators, when do they meet ?
    By apacz in forum Contests Board
    Replies: 1
    Last Post: 12-03-2005, 11:48 AM
  2. old HD, meet new computer
    By deathstryke in forum Tech Board
    Replies: 12
    Last Post: 12-05-2002, 06:04 PM
  3. if you could meet someone from here in live, who would it be?
    By doubleanti in forum A Brief History of
    Replies: 26
    Last Post: 01-19-2002, 07:48 PM