Saturday, May 26, 2018

Digest for comp.programming.threads@googlegroups.com - 5 updates in 5 topics

Sky89 <Sky89@sky68.com>: May 25 03:18PM -0400

Hello..
 
 
Large scale nuclear fusion could be here in just 15 years
 
Read more here:
 
https://www.weforum.org/agenda/2018/03/a-new-era-in-fusion-research-at-mit
 
 
Thank you,
Amine Moulay Ramdane.
Sky89 <Sky89@sky68.com>: May 25 02:19PM -0400

Hello,
 
 
Nuclear fusion on brink of being realised, say MIT scientists
 
Read more here:
 
https://www.theguardian.com/environment/2018/mar/09/nuclear-fusion-on-brink-of-being-realised-say-mit-scientists
 
 
 
Thank you,
Amine Moulay Ramdane.
Sky89 <Sky89@sky68.com>: May 25 11:05AM -0400

Hello..
 
 
Intel Wants You To Think Xeon When It Comes to Deep Learning
 
Read more here:
 
https://adtmag.com/articles/2018/05/07/intel-xeon-benchmark-for-ai.aspx
 
 
 
Thank you,
Amine Moulay Ramdane.
Sky89 <Sky89@sky68.com>: May 25 10:28AM -0400

Hello..
 
 
I have thought more about C++, and I think C++ is really powerful
because STL vectors perform bounds checking when the .at() member
function is called, but do not perform any checks on the [] operator
when out of bounds, the [] operator produces undefined results,
and for integer overflow or underflow or more efficient strict-type
safety, here is how to do it with SafeInt here:
 
https://github.com/dcleblanc/SafeInt
 
 
I have just written the following program using SafeInt, please look at
it and try it to notice that C++ is powerful:
 
===
 
#include "SafeInt.hpp"
using namespace std;
#include <climits>
#include <iostream>
#include <sstream>
#include <stdexcept>
 
class my_exception : public std::runtime_error {
std::string msg;
public:
my_exception(const std::string &arg, const char *file, int line) :
std::runtime_error(arg) {
std::ostringstream o;
o << file << ":" << line << ": " << arg;
msg = o.str();
}
~my_exception() throw() {}
const char *what() const throw() {
return msg.c_str();
}
};
 
#define throw_line(arg) throw my_exception(arg, __FILE__, \
__LINE__);
 
 
class CMySafeIntException : public SafeIntException
{
public:
static void SafeIntOnOverflow()
{
cout << "Caught a SafeInt Overflow exception!" << endl;
throw_line("SafeInt exception");
}
static void SafeIntOnDivZero()
{
cout << "Caught a SafeInt Divide By Zero exception!" << endl;
throw_line("SafeInt exception");
}
};
 
void a1(SafeInt<unsigned __int8, CMySafeIntException> a)
{
 
cout << (int)a << endl;
}
 
int main()
{
try {
 
//throw std::invalid_argument("exception");
 
unsigned __int8 i1 = 250;
unsigned __int8 i2 = 150;
SafeInt<unsigned __int8, CMySafeIntException> si1(i1);
SafeInt<unsigned __int8, CMySafeIntException> si2(i2);
SafeInt<unsigned __int8, CMySafeIntException> siResult = si1 + si2;
cout << (int)siResult << endl;
 
 
a1(-1);
 
}
catch (const std::runtime_error &ex) {
std::cout << ex.what() << std::endl;
}
//catch (const std::invalid_argument &ex) {
// std::cout << ex.what() << std::endl;
// }
 
 
}
 
 
====
 
So as you have noticed C++ is great !
 
 
 
Thank you,
Amine Moulay Ramdane.
Sky89 <Sky89@sky68.com>: May 25 10:16AM -0400

Hello..
 
 
I have thought more about C++, and I think C++ is really powerful
because STL vectors perform bounds checking when the .at() member
function is called, but do not perform any checks on the [] operator
when out of bounds, the [] operator produces undefined results,
and for integer overflow or more efficient strict-type safety, here
is how to do it with SafeInt here:
 
https://github.com/dcleblanc/SafeInt
 
 
I have just written the following program using SafeInt, please look at
it and try it to notice that C++ is powerful:
 
===
 
#include "SafeInt.hpp"
using namespace std;
#include <climits>
#include <iostream>
#include <sstream>
#include <stdexcept>
 
class my_exception : public std::runtime_error {
std::string msg;
public:
my_exception(const std::string &arg, const char *file, int line) :
std::runtime_error(arg) {
std::ostringstream o;
o << file << ":" << line << ": " << arg;
msg = o.str();
}
~my_exception() throw() {}
const char *what() const throw() {
return msg.c_str();
}
};
 
#define throw_line(arg) throw my_exception(arg, __FILE__, \
__LINE__);
 
 
class CMySafeIntException : public SafeIntException
{
public:
static void SafeIntOnOverflow()
{
cout << "Caught a SafeInt Overflow exception!" << endl;
throw_line("SafeInt exception");
}
static void SafeIntOnDivZero()
{
cout << "Caught a SafeInt Divide By Zero exception!" << endl;
throw_line("SafeInt exception");
}
};
 
void a1(SafeInt<unsigned __int8, CMySafeIntException> a)
{
 
cout << (int)a << endl;
}
 
int main()
{
try {
 
//throw std::invalid_argument("exception");
 
unsigned __int8 i1 = 250;
unsigned __int8 i2 = 150;
SafeInt<unsigned __int8, CMySafeIntException> si1(i1);
SafeInt<unsigned __int8, CMySafeIntException> si2(i2);
SafeInt<unsigned __int8, CMySafeIntException> siResult = si1 + si2;
cout << (int)siResult << endl;
 
 
a1(-1);
 
}
catch (const std::runtime_error &ex) {
std::cout << ex.what() << std::endl;
}
//catch (const std::invalid_argument &ex) {
// std::cout << ex.what() << std::endl;
// }
 
 
}
 
 
====
 
So as you have nmoticed C++ is great !
 
 
 
Thank you,
Amine Moulay Ramdane.
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.programming.threads+unsubscribe@googlegroups.com.

No comments: