Thread: Though implementation problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No warning. Change to uint8_t, I do get a warning.
    Wait. It might be because of something implementation. I'll run a test.
    EDIT: Now I get a warning for both.

    I see now. It's basically the same behavior as if doing with native types.
    Code:
    	uint8_t i = 0;
    	i += 0xFFFF; // Truncation
    	i += -1; // Signed/unsigned
    My fears are unfounded. Good.
    Last edited by Elysia; 05-31-2008 at 11:04 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    However, I still see no reason as to not use templates.
    I didn't say not to use templates. I'm against the notion of not using templates.

    They are a generic way of doing the same thing for an infinite range of types, right?
    No, but they can be used to express such a thing; even dumb C macros are capable of that.

    Since all types would be handled the same, I see it as a means to remove code duplication and maintenance for the class.
    You need to learn the difference between a class and a template class.

    The point stands, a template class can most certainly benefit from doing things properly because it may benefit every instantiation.

    The real beauty lies in that I can specialize a template if I need a specific type to behave differently.
    You can't specialize a template method; you can only specialize the behavior or overload the interface/implementation.

    Why attempt a specialization or partial specialization at some later point if you find you require a compiler that doesn't handle temporaries/forwarding well?

    Well, anyway, you have a possibility and a possible proof that it isn't useful here--as provided by CornedBee. So, what are you going to do with them?

    Soma

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I've already changed it to:
    Code:
    	CInt& operator %= (const CInt& Data);
    And it seems to behave just as with normal integers, so I'm all happy now with less complexity


    Ah yes, quick question:
    I'm trying to check for overflow/underflow, but instead of taking into account everything (including the possibility of negative numbers) and using templates/traits for max/min range of numbers, isn't there some assembly equalient that can check for overflow/underflow?
    I'm not sure if there are some other functions that may check or if it's possible to check in assembly after the operation has been done (ie check flags)?

    Suggestions?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I'm trying to check for overflow/underflow, but instead of taking into account everything (including the possibility of negative numbers) and using templates/traits for max/min range of numbers, isn't there some assembly equalient that can check for overflow/underflow?
    It depends on the architecture and operation, but I think 'x86' has a flag that it sets after an operation is performed if any overflow/underflow occurs.

    Soma

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    Why is this thread nearly 300 replies long?
    Haven't you fixed the original problem yet, or is this just a meandering "Elysia" support thread?

    Just a suggestion, but if these are new questions, they should be new threads, with links if you think it's relevant.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Oh, I could fit in a 100 questions to this generic topic title, but if you insist, I can make new threads.
    But I found it exciting to enlarge the thread and see how many replies could get crammed into it.

    Quote Originally Posted by phantomotap View Post
    It depends on the architecture and operation, but I think 'x86' has a flag that it sets after an operation is performed if any overflow/underflow occurs.
    Soma
    Yes, it's x86. I don't do much other than Windows™ programming.
    I'd rather do it in assembly than a fat code and additional complications to check for under/overflow.
    I'll try looking in an assembly manual.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I'd rather do it in assembly than a fat code and additional complications to check for under/overflow.
    So?! If you don't want "fat" code, write "lean" code. I mean: hack away...

    Soma

    hackersdelight.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. implementation file
    By bejiz in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2005, 01:59 AM
  4. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  5. Memory Problem - I think...
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-24-2001, 12:14 PM