Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by WebDrake

  1. WebDrake

    Object-oriented programming: Objective-C or C++?

    I really loved Kochan's C book; it's a fantastic resource and getting it made some major improvements to my skills and understanding. I wish he'd written one for C++, since in the short term that's the language I've decided to go with, but I'll keep ObjC in mind for the future.
  2. WebDrake

    Object-oriented programming: Objective-C or C++?

    Not really true. A statement like a = malloc(10*sizeof(*a)); is good code and makes sense in C, but won't work in C++. The code that will work in C++, such as, a = (int *)malloc(10*sizeof(int)); is problematic from a C point of view, because the cast prevents the C compiler from...
  3. WebDrake

    Tracing a rounding error

    Belated thanks for the useful replies. And yes, I know it's normal floating point behaviour. I'm just interested in tracing when numerical methods diverge. :-)
  4. WebDrake

    Tracing a rounding error

    Sure. I know the principle, I was just wondering if there was any advice on how to trace exactly where such an error comes in. My impression was that the error was occurring in the event of something like this happening: x += a; x -= a; Where a is of much greater order than x (e.g. a...
  5. WebDrake

    Tracing a rounding error

    I'm wondering if anyone can give any advice on tracing a rounding error in a program. I have two slightly different implementations of a process, which basically come down to the following. In Version 1, various increments are added to a double variable, and at the end I check to see if it is...
  6. WebDrake

    Some issues with mixing C and C++

    Well, C++ doesn't like malloc() statements much, unless they're cast. :-( With C I compile with the flags -ansi -pedantic -Wall, so, the strictest C89 compatibility (I believe?). Regarding your suggestion for the extern "C" { problem, I think I'll still have the same annoying unwanted...
  7. WebDrake

    Code efficiency question

    Hi Dian, Thanks for the thoughts. For what it's worth, I am talking about having very large numbers, so little savings are often important. In the case of this particular loop, N will not be large; but the whole thing will be contained in a bigger loop that will go round on the order of 100...
  8. WebDrake

    Code efficiency question

    I'm aware of that. For the case I'm concerned with, check remains at a single value throughout either option.
  9. WebDrake

    Code efficiency question

    Does anyone have any comments on which of these pieces of code will run more efficiently? In these code examples, check is a variable of type bool (it is an actual variable, not an expression that is reevaluated each time the if() statement is run), and i and N are unsigned ints. if(check) {...
  10. WebDrake

    Some issues with mixing C and C++

    I've started introducing some C++ modules to my code project (scientific number-crunching), where it's convenient to do so, and have been following the instructions at http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html for mixing code. A few things are niggling me, mostly trivial, but...
  11. WebDrake

    Object-oriented programming: Objective-C or C++?

    Good point. Does ObjC have an ANSI standard? I recall that C++ does. As for portability, I'm unlikely to be using my code on any systems where gcc will not run.
  12. WebDrake

    Object-oriented programming: Objective-C or C++?

    AAARRRGHHHHH! You know I wouldn't actually use it like that, right? :-)
  13. WebDrake

    Pointers to constants?

    Am I just being thick here or... ... well, if I understand you right, the second argument is a pointer to the value you wish to write, or read to. So if x is the variable whose value you wish to pass, you would write, status = EEPROM_IO(0,&x,(unsigned int)EEPROM_SIZE,CLEAR); ... right? So...
  14. WebDrake

    Array lengths

    I've already fallen for that one, or rather, thought it up, found it didn't work and quickly realised why (it doesn't work for the same reason that sizeof(*a) does work, right?). Almost invariably when I'm dealing with arrays, they are malloc'd pointers, so this isn't a solution. I guess...
  15. WebDrake

    Object-oriented programming: Objective-C or C++?

    I noticed... ::sigh:: Thanks very much for helpful advice! :-)

Part and Inventory Search

Back
Top