github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/unit/constant/electricconstant.go (about) 1 // Code generated by "go generate github.com/jingcheng-WU/gonum/unit/constant”; DO NOT EDIT. 2 3 // Copyright ©2019 The Gonum Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package constant 8 9 import ( 10 "fmt" 11 12 "github.com/jingcheng-WU/gonum/unit" 13 ) 14 15 // ElectricConstant is the electric constant (ε₀), the value of the absolute dielectric permittivity of classical vacuum. 16 // The dimensions of ElectricConstant are A^2 s^4 kg^-1 m^-3. The standard uncertainty of the constant is 1.3e-21 A^2 s^4 kg^-1 m^-3. 17 const ElectricConstant = electricConstantUnits(8.854187817620389e-12) 18 19 type electricConstantUnits float64 20 21 // Unit converts the electricConstantUnits to a *unit.Unit 22 func (cnst electricConstantUnits) Unit() *unit.Unit { 23 return unit.New(float64(cnst), unit.Dimensions{ 24 unit.CurrentDim: 2, 25 unit.TimeDim: 4, 26 unit.MassDim: -1, 27 unit.LengthDim: -3, 28 }) 29 } 30 31 func (cnst electricConstantUnits) Format(fs fmt.State, c rune) { 32 switch c { 33 case 'v': 34 if fs.Flag('#') { 35 fmt.Fprintf(fs, "%T(%v)", cnst, float64(cnst)) 36 return 37 } 38 fallthrough 39 case 'e', 'E', 'f', 'F', 'g', 'G': 40 p, pOk := fs.Precision() 41 w, wOk := fs.Width() 42 switch { 43 case pOk && wOk: 44 fmt.Fprintf(fs, "%*.*"+string(c), w, p, cnst.Unit()) 45 case pOk: 46 fmt.Fprintf(fs, "%.*"+string(c), p, cnst.Unit()) 47 case wOk: 48 fmt.Fprintf(fs, "%*"+string(c), w, cnst.Unit()) 49 default: 50 fmt.Fprintf(fs, "%"+string(c), cnst.Unit()) 51 } 52 default: 53 fmt.Fprintf(fs, "%%!"+string(c)+"(constant.electricConstantUnits=%v A^2 s^4 kg^-1 m^-3)", float64(cnst)) 54 } 55 }