DP-S-Script/Dps_A/BaseClass/BigInt/BigInt.nut

57 lines
1.5 KiB
Plaintext

/*
文件名:BigInt.nut
路径:Dps_A/BaseClass/BigInt/BigInt.nut
创建日期:2025-03-25 18:28
文件用途:大数字类
*/
class longlong {
Value = null;
//构造函数 不管是不是string类型都要转成string类型
constructor(arg) {
if( typeof arg == "string"){
Value = arg;
}
else if( typeof arg == "integer"){
Value = arg.tostring();
}
else if ( typeof arg == "userdata"){
local Str = "" + arg;
Str = Str.slice(Str.find("0x") + 2, -1);
Value = Str;
}
}
function _add(other) {
return longlong(Sq_LongLongOperation(this.Value, other.Value, "+"));
}
function _sub(other) {
return longlong(Sq_LongLongOperation(this.Value, other.Value, "-"));
}
function _mul(other) {
return longlong(Sq_LongLongOperation(this.Value, other.Value, "*"));
}
function _div(other) {
return Sq_LongLongOperation(this.Value, other.Value, "/");
}
function _unm() {
return longlong(Sq_LongLongOperation(longlong("0"), this.Value, "-"));
}
function _modulo(other) {
return longlong(Sq_LongLongOperation(this.Value, other.Value, "%"));
}
function GetFormat(FType) {
local Buf = Sq_LongLongOperation(this.Value, FType, "format");
if (Buf.len()< 2) return Buf + ".0";
local Value = Buf.slice(0, -1);
local Unit = Buf.slice(-1);
local RetStr = format(FType + Unit, Value.tofloat());
return RetStr;
}
}