Search Results

Search found 8 results on 1 pages for 'evilteach'.

Page 1/1 | 1 

  • Base 36 to Base 10 conversion using SQL only.

    - by EvilTeach
    A situation has arisen where I need to perform a base 36 to base 10 conversion, in the context of a SQL statement. There doesn't appear to be anything built into Oracle 9, or Oracle 10 to address this sort of thing. My Google-Fu, and AskTom suggest creating a pl/sql function to deal with the task. That is not an option for me at this point. I am looking for suggestions on an approach to take that might help me solve this issue. To put this into a visual form... WITH Base36Values AS ( SELECT '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' myBase36 FROM DUAL ), TestValues AS ( SELECT '01Z' BASE36_VALUE, 71 BASE10_VALUE FROM DUAL ) SELECT * FROM Base36Values, TestValues I am looking for something to calculate the value 71, based on the input 01Z. As a bribe, each useful answer gets a free upvote. Thanks Evil.

    Read the article

  • What does msvc 6 throw when an integer divide by zero occurs?

    - by EvilTeach
    I have been doing a bit of experimenting, and have discovered that an exception is being thrown, when an integer divide by zero occurs. #include <iostream> #include <stdexcept> using namespace std; int main ( void ) { try { int x = 3; int y = 0; int z = x / y; cout << "Didn't throw or signal" << endl; } catch (std::exception &e) { cout << "Caught exception " << e.what() << endl; } return 0; } Clearly it is not throwing a std::exception. What else might it be throwing?

    Read the article

  • Traveling Salesman - Nearest Neighbor vs Genetic DEATHMATCH

    - by EvilTeach
    Over the last few days I have noted a few web sites that demonstrated TS solution using genetic algorithms. I am looking for your opinion which is better for this particular problem. Heuristics vs Genetic. By better, I mean will yield a shorter/lower cost path. Explain why you feel the way that you do. Examples, and off-site links are welcome.

    Read the article

  • Someone is using the struct name as a variable name too. What does the code really say? (c++)

    - by EvilTeach
    This morning we found an old chunk of code that was causing a library call to crash. struct fred { int a; int b; int c; }; fred fred[MAX_SIZE+1]; memset( fred, 0, sizeof(fred) * MAX_SIZE+1 ); It appears that the sizeof(fred) may have been the full array size, rather than the structure size, as it was overwriting a great deal of memory. The fact that it compiled without warning on several different systems seemed odd. Is there a correct semantic for this case where the type and variable name are colliding? or is this some sort of undefined behavior? or just a defect? I haven't been been clever enough to find anything on Google or our language help. Thanks Evil

    Read the article

  • Bejeweled Blitz - How does it assert there is always a move?

    - by EvilTeach
    I have been playing Bejeweled Blitz for a while now. Yes, it is an addiction. In thinking about the game, I have observed that on some boards, the bottom runs dry (no moves) leaving only the top part of the board playable. Frequently that part of the board drys up, and one is left with moves in area cleared by the last move. The board never runs completely dry, so clearly the program is doing some sorts of calculation that allows it to choose what to drop to prevent it from running dry. I have noticed in this 'mode' that it is very common for the algorithm to drop jewels which causes more non-dry area to appear in the horizontal area. Perhaps less frequent is a drop which seems designed to open up the bottom part of the board again. So my question is "How would one go about designing an algorithm guarantee that there is always a move available.?"

    Read the article

  • Looking for a better way to integrate a static list into a set of classes

    - by EvilTeach
    I'm trying to expand my sons interest from Warcraft 3 programming into C++ to broaden his horizons to a degree. We are planning on porting a little game that he wrote. The context goes something like this. There are Ships and Missiles, for which Ships will use Missiles and interact with them A Container exists which will hold 'a list' of ships. A Container exists which will hold 'a list' of planets. One can apply a function over all elements in the Container (for_each) Ships and Missles can be created/destroyed at any time New objects automatically insert themselves into the proper container. I cobbled a small example together to do that job, so we can talk about topics (list, templates etc) but I am not pleased with the results. #include <iostream> #include <list> using namespace std; /* Base class to hold static list in common with various object groups */ template<class T> class ObjectManager { public : ObjectManager ( void ) { cout << "Construct ObjectManager at " << this << endl; objectList.push_back(this); } virtual ~ObjectManager ( void ) { cout << "Destroy ObjectManager at " << this << endl; } void for_each ( void (*function)(T *) ) { for (objectListIter = objectList.begin(); objectListIter != objectList.end(); ++objectListIter) { (*function)((T *) *objectListIter); } } list<ObjectManager<T> *>::iterator objectListIter; static list<ObjectManager<T> *> objectList; }; /* initializer for static list */ template<class T> list<ObjectManager<T> *> ObjectManager<T>::objectList; /* A simple ship for testing */ class Ship : public ObjectManager<Ship> { public : Ship ( void ) : ObjectManager<Ship>() { cout << "Construct Ship at " << this << endl; } ~Ship ( void ) { cout << "Destroy Ship at " << this << endl; } friend ostream &operator<< ( ostream &out, const Ship &that ) { out << "I am a ship"; return out; } }; /* A simple missile for testing */ class Missile : public ObjectManager<Missile> { public : Missile ( void ) : ObjectManager<Missile>() { cout << "Construct Missile at " << this << endl; } ~Missile ( void ) { cout << "Destroy Missile at " << this << endl; } friend ostream &operator<< ( ostream &out, const Missile &that ) { out << "I am a missile"; return out; } }; /* A function suitable for the for_each function */ template <class T> void show ( T *it ) { cout << "Show: " << *it << " at " << it << endl; } int main ( void ) { /* Create dummy planets for testing */ Missile p1; Missile p2; /* Demonstrate Iterator */ p1.for_each(show); /* Create dummy ships for testing */ Ship s1; Ship s2; Ship s3; /* Demonstrate Iterator */ s1.for_each(show); return 0; } Specifically, The list is effectively embedded in each ship though the inheritance mechanism. One must have a ship, in order to access the list of ships. One must have a missile in order to be able to access the list of missiles. That feels awkward. My question boils down to "Is there a better way to do this?" Automatic object container creation Automatic object insertion Container access without requiring an object in the list to access it. I am looking for better ideas. All helpful entries get an upvote. Thanks Evil.

    Read the article

  • Coding Practices which enable the compiler/optimizer to make a faster program.

    - by EvilTeach
    Many years ago, C compilers were not particularly smart. As a workaround K&R invented the register keyword, to hint to the compiler, that maybe it would be a good idea to keep this variable in an internal register. They also made the tertiary operator to help generate better code. As time passed, the compilers matured. They became very smart in that their flow analysis allowing them to make better decisions about what values to hold in registers than you could possibly do. The register keyword became unimportant. FORTRAN can be faster than C for some sorts of operations, due to alias issues. In theory with careful coding, one can get around this restriction to enable the optimizer to generate faster code. What coding practices are available that may enable the compiler/optimizer to generate faster code? Identifying the platform and compiler you use, would be appreciated. Why does the technique seem to work? Sample code is encouraged. Here is a related question [Edit] This question is not about the overall process to profile, and optimize. Assume that the program has been written correctly, compiled with full optimization, tested and put into production. There may be constructs in your code that prohibit the optimizer from doing the best job that it can. What can you do to refactor that will remove these prohibitions, and allow the optimizer to generate even faster code? [Edit] Offset related link

    Read the article

1