...

Source file src/strconv/ftoaryu_test.go

Documentation: strconv

		 1  // Copyright 2021 The Go Authors. All rights reserved.
		 2  // Use of this source code is governed by a BSD-style
		 3  // license that can be found in the LICENSE file.
		 4  
		 5  package strconv_test
		 6  
		 7  import (
		 8  	"math"
		 9  	. "strconv"
		10  	"testing"
		11  )
		12  
		13  func TestMulByLog2Log10(t *testing.T) {
		14  	for x := -1600; x <= +1600; x++ {
		15  		iMath := MulByLog2Log10(x)
		16  		fMath := int(math.Floor(float64(x) * math.Ln2 / math.Ln10))
		17  		if iMath != fMath {
		18  			t.Errorf("mulByLog2Log10(%d) failed: %d vs %d\n", x, iMath, fMath)
		19  		}
		20  	}
		21  }
		22  
		23  func TestMulByLog10Log2(t *testing.T) {
		24  	for x := -500; x <= +500; x++ {
		25  		iMath := MulByLog10Log2(x)
		26  		fMath := int(math.Floor(float64(x) * math.Ln10 / math.Ln2))
		27  		if iMath != fMath {
		28  			t.Errorf("mulByLog10Log2(%d) failed: %d vs %d\n", x, iMath, fMath)
		29  		}
		30  	}
		31  }
		32  

View as plain text