- Best way to handle mathematical divide-by-zero case - 4 Updates
- Dependent definitions - 1 Update
- primitive function input/output param encapsulation.. - 2 Updates
- delete pointer type user defined object - 1 Update
JiiPee <no@notvalid.com>: Jan 14 09:02PM On 14/01/2017 20:45, Chris M. Thomasson wrote: > The main problem is that an iteration uses information from previous > iterations. Nans and/or Infinities can propagate throughout the > subsequent iterations, and drastically alter the rendering. Like a virus. Yes sure 0 is better in most cases as a wrong value. And if its logged to the file then sure its quite ok, then can see the error. |
"Chris M. Thomasson" <invalid@invalid.invalid>: Jan 14 01:03PM -0800 On 1/14/2017 12:45 PM, Chris M. Thomasson wrote: >> So, instead of getting NaN as answer, you get the wrong answer? > In a sense you are correct, however I can review the log and see exactly > how things got to a div-by-zero. [...] > I am worried about > passing sqrt a negative number... Not sure why I was so focused on the div-by-zero case, and sort of mixed it up with nan and infinities individual cases. Sorry for the confusion I had to of caused. ;^o |
"Chris M. Thomasson" <invalid@invalid.invalid>: Jan 14 01:47PM -0800 On 1/14/2017 1:02 PM, JiiPee wrote: >> subsequent iterations, and drastically alter the rendering. Like a virus. > Yes sure 0 is better in most cases as a wrong value. And if its logged > to the file then sure its quite ok, then can see the error. Indeed. Except I set 0 to epsilon. Sometimes, I also try to propagate the signs of the offending formula and/or value of z, wrt to +-epsilon for each offense. This is dangerous wrt sqrt, and other nasal demons. Think of running an unknown formula, and you have to look after the damn possible moron! |
David Brown <david.brown@hesbynett.no>: Jan 15 12:16AM +0100 On 14/01/17 21:30, Ben Bacarisse wrote: >> sometimes, no matter what value you pick. > Then you've lost me. The input in your example is not wrong -- zero > consumption is perfectly normal, quite unlike an average of nothing. I was not trying to explain how a fridge might figure out your coke consumption - I was trying to show how returning 99999999999 as an "obviously wrong" answer when a function is given garbage, is no better than returning 0. It really doesn't matter what the function is, or what it does - it's just a function that is unspecified for some inputs. |
David Brown <david.brown@hesbynett.no>: Jan 15 12:11AM +0100 On 14/01/17 16:05, Paul wrote: > int x = 7, y = f(x); > std::cout << y; > } This is the kind of question you only have to ask if you are dealing with other people's code. If you are writing code yourself, simply don't do that sort of thing - it makes it harder to understand, and easier to get wrong. Write: int x = 7; int y = f(x); No one can possibly misinterpret that. |
"Chris M. Thomasson" <invalid@invalid.invalid>: Jan 14 02:34PM -0800 On 1/12/2017 10:11 PM, Alf P. Steinbach wrote: > Well, they made a mess of things, but why? > I am ~100% sure that a main problem is that they thought they could > replace intelligence with mechanical rules. There better be a mechanical override that the intelligence can try before a hidden, hard to find coding failure in the senor array net can potentially radically expose the ship down to Terra-Contact explosion like conditions, without an eject; another subject are the ejection system codes. Now to think of the correctness of the various dangerous weapons systems. A lot of detail in creating a warplane. > would use that to communicate failures from his own code. But what is > the result of using dumb programmers to create the system? > Oh, we've seen the result. :( Indeed! ;^o Preaching to the choir wrt errno: search the text in the following page for "errno"-> http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_timedwait.html http://man7.org/linux/man-pages/man3/sem_wait.3.html ahhh, semaphores. ;^) |
"Chris M. Thomasson" <invalid@invalid.invalid>: Jan 14 02:47PM -0800 On 1/14/2017 2:34 PM, Chris M. Thomasson wrote: >> replace intelligence with mechanical rules. > There better be a mechanical override that the intelligence can try > before a hidden, hard to find coding failure in the senor array net can ^^^^^^^^^^^^^^^^^^^^^ Not senor! damn it. before a hidden, hard to find coding failure in the _sensor_ array net can |
ram@zedat.fu-berlin.de (Stefan Ram): Jan 14 09:08PM > Join *j=new Join(with some parameter of constructor); >//after that i push it to vector of this class type(pointer type); >vector.push_back(j); You can emplace your objects directly into the vector, and there will be no need to delete, and it will be much more efficient. #include <algorithm> #include <initializer_list> #include <iostream> #include <ostream> #include <vector> #include <string> using namespace ::std::literals; struct join { int i; explicit join( int const i ): i{ i } {} }; int main() { { ::std::vector< join >v; for( int i = 0; i < 9; ++i )v.emplace_back( i * 2 + 2 ); for_each ( cbegin( v ), cend( v ), []( join const & j ){ ::std::cout << j.i << '\n'; }); } /* v and all is gone here, no need to "delete". */ } If you really need pointers, you might use unique_ptrs. #include <algorithm> #include <initializer_list> #include <memory> #include <iostream> #include <ostream> #include <vector> #include <string> using namespace ::std::literals; struct join { int i; explicit join( int const i ): i{ i } {} }; int main() { { ::std::vector< ::std::unique_ptr< join >>v; for( int i = 0; i < 9; ++i ) v.push_back( ::std::make_unique< join >( i * 2 + 2 )); for_each ( begin( v ), end( v ), []( ::std::unique_ptr< join >& j ) { ::std::cout << j->i << '\n'; }); } /* v and all is gone here, no need to "delete". */ } |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment