Commit 9cdb8bd5 authored by Russ Cox's avatar Russ Cox

minor int/float fixes

R=ken
OCL=18032
CL=18032
parent 11a978ad
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
package main package main
func func
pow10(pow int) double pow10(pow int) float64
{ {
if pow < 0 { return 1/pow10(-pow); } if pow < 0 { return 1/pow10(-pow); }
if pow > 0 { return pow10(pow-1)*10; } if pow > 0 { return pow10(pow-1)*10; }
...@@ -15,9 +15,9 @@ pow10(pow int) double ...@@ -15,9 +15,9 @@ pow10(pow int) double
} }
func func
close(da double, ia, ib int64, pow int) bool close(da float64, ia, ib int64, pow int) bool
{ {
db := double(ia) / double(ib); db := float64(ia) / float64(ib);
db *= pow10(pow); db *= pow10(pow);
if da == 0 { if da == 0 {
......
...@@ -20,7 +20,7 @@ func main() { ...@@ -20,7 +20,7 @@ func main() {
} }
var l = len(s); var l = len(s);
for w, i, j := 0,0,0; i < l; i += w { for w, i, j := 0,0,0; i < l; i += w {
var r int32; var r int;
r, w = sys.stringtorune(s, i); r, w = sys.stringtorune(s, i);
if w == 0 { panic("zero width in string") } if w == 0 { panic("zero width in string") }
if r != chars[j] { panic("wrong value from string") } if r != chars[j] { panic("wrong value from string") }
...@@ -43,7 +43,7 @@ func main() { ...@@ -43,7 +43,7 @@ func main() {
a[10] = 0xaa; a[10] = 0xaa;
a[11] = 0x9e; a[11] = 0x9e;
for w, i, j := 0,0,0; i < L; i += w { for w, i, j := 0,0,0; i < L; i += w {
var r int32; var r int;
r, w = sys.bytestorune(&a[0], i, L); r, w = sys.bytestorune(&a[0], i, L);
if w == 0 { panic("zero width in bytes") } if w == 0 { panic("zero width in bytes") }
if r != chars[j] { panic("wrong value from bytes") } if r != chars[j] { panic("wrong value from bytes") }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment