校对了数据,上海的没啥问题,深圳的还不行

This commit is contained in:
钱纯净
2024-10-24 22:23:06 +08:00
parent 1bdc7ef8e1
commit 9c7923d939
6 changed files with 107 additions and 81 deletions

View File

@@ -2,6 +2,7 @@ package protocol
import (
"bytes"
"fmt"
bytes2 "github.com/injoyai/base/bytes"
"github.com/injoyai/conv"
"golang.org/x/text/encoding/simplifiedchinese"
@@ -32,41 +33,24 @@ func UTF8ToGBK(text []byte) []byte {
return bytes.ReplaceAll(content, []byte{0x00}, []byte{})
}
func getprice(b []byte, pos *int) int {
/*
0x7f与常量做与运算实质是保留常量转换为二进制形式的后7位数既取值区间为[0,127]
0x3f与常量做与运算实质是保留常量转换为二进制形式的后6位数既取值区间为[0,63]
0x80 1000 0000
0x7f 0111 1111
0x40 100 0000
0x3f 011 1111
*/
posByte := 6
bData := b[*pos]
data := int(bData & 0x3f)
bSign := false
if (bData & 0x40) > 0 {
bSign = true
func FloatUnit(f float64) (float64, string) {
m := []string{"万", "亿"}
unit := ""
for i := 0; f > 1e4 && i < len(m); f /= 1e4 {
unit = m[i]
}
if (bData & 0x80) > 0 {
for {
*pos += 1
bData = b[*pos]
data += (int(bData&0x7f) << posByte)
posByte += 7
if (bData & 0x80) <= 0 {
break
}
}
}
*pos++
if bSign {
data = -data
}
return data
return f, unit
}
func FloatUnitString(f float64) string {
m := []string{"万", "亿"}
unit := ""
for i := 0; f > 1e4 && i < len(m); f /= 1e4 {
unit = m[i]
}
return fmt.Sprintf("%0.2f%s", f, unit)
}
func IntUnitString(n int) string {
return FloatUnitString(float64(n))
}