mirror of
https://github.com/Luzifer/sii.git
synced 2024-10-18 05:14:19 +00:00
Support negative float values
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a26d79eefb
commit
ab32292dfe
3 changed files with 3 additions and 3 deletions
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
// float2-4 => [2]float - [4]float
|
||||
|
||||
var placementRegexp = regexp.MustCompile(`^\(([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+)\) \(([0-9.]+|&[0-9a-f]+); ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+)\)$`)
|
||||
var placementRegexp = regexp.MustCompile(`^\(([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+)\) \(([0-9.-]+|&[0-9a-f]+); ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+)\)$`)
|
||||
|
||||
// Placement contains 7 floats: (x, y, z) (w; x, y, z)
|
||||
type Placement [7]float32
|
||||
|
|
|
@ -113,7 +113,7 @@ func genericUnmarshal(in []byte, out interface{}, unit *Unit) error {
|
|||
switch typeField.Type.Len() {
|
||||
|
||||
case 3:
|
||||
grps := regexp.MustCompile(`^\(([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+)\)$`).
|
||||
grps := regexp.MustCompile(`^\(([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+)\)$`).
|
||||
FindSubmatch(getSingleValue(in, attributeName))
|
||||
var v [3]float32
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ func float2sii(f float32) ([]byte, error) {
|
|||
err error
|
||||
)
|
||||
|
||||
if math.Floor(float64(f)) == float64(f) && f < 1000 {
|
||||
if math.Floor(float64(f)) == float64(f) && f < 1000 && f > -1000 {
|
||||
return []byte(fmt.Sprintf("%.0f", f)), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue