代码拉取完成,页面将自动刷新
// Copyrights by Kenneth Lee, 2022. All Rights Reserved
#include "float_val.hpp"
FloatVal::FloatVal(int i) {
v = (float)i;
state = ST_VAL;
}
FloatVal::FloatVal() {
state = ST_NON;
}
FloatVal::FloatVal(const char *s) {
*this = FloatVal(atoi(s));
}
bool operator==(const FloatVal &l, const FloatVal &r) {
if (!((ValIf)l).state_compare((ValIf &)r))
return false;
return l.v == r.v;
}
ostream & operator<<(ostream & os, const FloatVal & v) {
if (v.state != ValIf::ST_VAL)
((ValIf)v).show(os);
else
os << v.v;
return os;
}
FloatVal operator+(const FloatVal &l, const FloatVal &r) {
FloatVal ret;
if (((ValIf&)ret).op_init(l, r))
ret.v = l.v + r.v;
return ret;
}
FloatVal operator-(const FloatVal &l, const FloatVal &r) {
FloatVal ret;
if (((ValIf&)ret).op_init(l, r))
ret.v = l.v - r.v;
return ret;
}
FloatVal operator*(const FloatVal &l, const FloatVal &r) {
FloatVal ret;
if (((ValIf&)ret).op_init(l, r))
ret.v = l.v * r.v;
return ret;
}
FloatVal operator/(const FloatVal &l, const FloatVal &r) {
FloatVal ret;
if (((ValIf&)ret).op_init(l, r)) {
if (r.v != 0)
ret.v = l.v / r.v;
else {
ret.state = ValIf::ST_INV;
}
}
return ret;
}
FloatVal & FloatVal::operator=(const char *s) {
*this = FloatVal(atoi(s));
return *this;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。