File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -898,20 +898,33 @@ func (d Decimal) Lsh(bits uint) Decimal {
898
898
899
899
if d .coef .bigInt != nil {
900
900
d .coef .bigInt = d .coef .bigInt .Lsh (d .coef .bigInt , bits )
901
- } else {
902
- d .coef .u128 = d .coef .u128 .Lsh (bits )
901
+ return d
902
+ }
903
+
904
+ if bits >= 128 || (d .coef .u128 .hi > 0 && bits >= 64 ) ||
905
+ (d .coef .u128 .hi > 0 && (d .coef .u128 .hi << bits )>> bits != d .coef .u128 .hi ) {
906
+ bigInt := d .coef .GetBig ()
907
+ bigInt = bigInt .Lsh (bigInt , bits )
908
+ return newDecimal (d .neg , bintFromBigInt (bigInt ), d .prec )
903
909
}
904
910
911
+ d .coef .u128 = d .coef .u128 .Lsh (bits )
912
+
905
913
return d
906
914
}
907
915
908
916
func (d Decimal ) Rsh (bits uint ) Decimal {
917
+ if bits == 0 {
918
+ return d
919
+ }
920
+
909
921
if d .coef .bigInt != nil {
910
922
d .coef .bigInt = d .coef .bigInt .Rsh (d .coef .bigInt , bits )
911
- } else {
912
- d .coef .u128 = d .coef .u128 .Rsh (bits )
923
+ return d
913
924
}
914
925
926
+ d .coef .u128 = d .coef .u128 .Rsh (bits )
927
+
915
928
return d
916
929
}
917
930
You can’t perform that action at this time.
0 commit comments