File tree 2 files changed +15
-13
lines changed
2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ const (
198
198
_CD = 1 << 4 // checking disabled
199
199
)
200
200
201
- // Various constants used in the LOC RR. See RFC 1887 .
201
+ // Various constants used in the LOC RR. See RFC 1876 .
202
202
const (
203
203
LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2.
204
204
LOC_PRIMEMERIDIAN = 1 << 31 // RFC 1876, Section 2.
@@ -792,7 +792,10 @@ type LOC struct {
792
792
793
793
// cmToM takes a cm value expressed in RFC 1876 SIZE mantissa/exponent
794
794
// format and returns a string in m (two decimals for the cm).
795
- func cmToM (m , e uint8 ) string {
795
+ func cmToM (x uint8 ) string {
796
+ m := x & 0xf0 >> 4
797
+ e := x & 0x0f
798
+
796
799
if e < 2 {
797
800
if e == 1 {
798
801
m *= 10
@@ -848,10 +851,9 @@ func (rr *LOC) String() string {
848
851
s += fmt .Sprintf ("%.0fm " , alt )
849
852
}
850
853
851
- s += cmToM (rr .Size & 0xf0 >> 4 , rr .Size & 0x0f ) + "m "
852
- s += cmToM (rr .HorizPre & 0xf0 >> 4 , rr .HorizPre & 0x0f ) + "m "
853
- s += cmToM (rr .VertPre & 0xf0 >> 4 , rr .VertPre & 0x0f ) + "m"
854
-
854
+ s += cmToM (rr .Size ) + "m "
855
+ s += cmToM (rr .HorizPre ) + "m "
856
+ s += cmToM (rr .VertPre ) + "m"
855
857
return s
856
858
}
857
859
Original file line number Diff line number Diff line change @@ -5,37 +5,37 @@ import (
5
5
)
6
6
7
7
func TestCmToM (t * testing.T ) {
8
- s := cmToM (0 , 0 )
8
+ s := cmToM (( 0 << 4 ) + 0 )
9
9
if s != "0.00" {
10
10
t .Error ("0, 0" )
11
11
}
12
12
13
- s = cmToM (1 , 0 )
13
+ s = cmToM (( 1 << 4 ) + 0 )
14
14
if s != "0.01" {
15
15
t .Error ("1, 0" )
16
16
}
17
17
18
- s = cmToM (3 , 1 )
18
+ s = cmToM (( 3 << 4 ) + 1 )
19
19
if s != "0.30" {
20
20
t .Error ("3, 1" )
21
21
}
22
22
23
- s = cmToM (4 , 2 )
23
+ s = cmToM (( 4 << 4 ) + 2 )
24
24
if s != "4" {
25
25
t .Error ("4, 2" )
26
26
}
27
27
28
- s = cmToM (5 , 3 )
28
+ s = cmToM (( 5 << 4 ) + 3 )
29
29
if s != "50" {
30
30
t .Error ("5, 3" )
31
31
}
32
32
33
- s = cmToM (7 , 5 )
33
+ s = cmToM (( 7 << 4 ) + 5 )
34
34
if s != "7000" {
35
35
t .Error ("7, 5" )
36
36
}
37
37
38
- s = cmToM (9 , 9 )
38
+ s = cmToM (( 9 << 4 ) + 9 )
39
39
if s != "90000000" {
40
40
t .Error ("9, 9" )
41
41
}
You can’t perform that action at this time.
0 commit comments