Skip to content

Commit

Permalink
hot fix
Browse files Browse the repository at this point in the history
fix check overflow of operator-
RWFile: each line return 0 by default when an error occurred
  • Loading branch information
viplazylmht committed Jun 4, 2020
1 parent 8194bda commit 0d1491d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions QInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ QInt QInt::toConvertBu2() const
}
QInt QInt::operator- (const QInt& A) const
{
if ((A < 0) && (A > MAX_VALUE() + *this)) throw("Overflow");
if ((A > 0) && (A < MIN_VALUE() + *this)) throw("Overflow");
if ((A < 0) && (*this > MAX_VALUE() + A)) throw("Overflow");
if ((A > 0) && (*this < MIN_VALUE() + A)) throw("Overflow");

// Subtraction without check overflow
QInt result = *this;
Expand Down
4 changes: 2 additions & 2 deletions QInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class QInt
// dung union de int8 va int32 tro cung 1 vung nho
union {

// bug cuc manh o int8, vui long khong xai truc tiep, hay xem ham byteAt giai thich (doi voi trinh bien dich cua windows, g++)
// vui long khong xai truc tiep int8, hay xem ham byteAt giai thich (khong dung doi voi windows, unix/linux)
unsigned char int8[N_BYTE];
unsigned int int32[N_UINT];

unsigned char& byteAt(int pos) {
// use this funtion only when machine use Big Endian by default
// use this funtion only when machine use Little Endian by default
// for more infomation, see this answer: https://stackoverflow.com/a/47335692

int mod = pos % 4;
Expand Down
3 changes: 2 additions & 1 deletion RWFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ bool RWFile::Start()
{
stringstream exeption;
exeption << "ERROR Line " << count << ": " << result;
this->results.push_back(exeption.str());
//this->results.push_back(exeption.str());
this->results.push_back(string("0"));
}
}

Expand Down

0 comments on commit 0d1491d

Please sign in to comment.