1// Code generated by "go generate gonum.org/v1/gonum/unit”; DO NOT EDIT. 2 3// Copyright ©2014 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 7package unit 8 9import ( 10 "errors" 11 "fmt" 12 "math" 13 "unicode/utf8" 14) 15 16// Inductance represents an electrical inductance in Henry. 17type Inductance float64 18 19const ( 20 Yottahenry Inductance = 1e24 21 Zettahenry Inductance = 1e21 22 Exahenry Inductance = 1e18 23 Petahenry Inductance = 1e15 24 Terahenry Inductance = 1e12 25 Gigahenry Inductance = 1e9 26 Megahenry Inductance = 1e6 27 Kilohenry Inductance = 1e3 28 Hectohenry Inductance = 1e2 29 Decahenry Inductance = 1e1 30 Henry Inductance = 1.0 31 Decihenry Inductance = 1e-1 32 Centihenry Inductance = 1e-2 33 Millihenry Inductance = 1e-3 34 Microhenry Inductance = 1e-6 35 Nanohenry Inductance = 1e-9 36 Picohenry Inductance = 1e-12 37 Femtohenry Inductance = 1e-15 38 Attohenry Inductance = 1e-18 39 Zeptohenry Inductance = 1e-21 40 Yoctohenry Inductance = 1e-24 41) 42 43// Unit converts the Inductance to a *Unit 44func (i Inductance) Unit() *Unit { 45 return New(float64(i), Dimensions{ 46 CurrentDim: -2, 47 LengthDim: 2, 48 MassDim: 1, 49 TimeDim: -2, 50 }) 51} 52 53// Inductance allows Inductance to implement a Inductancer interface 54func (i Inductance) Inductance() Inductance { 55 return i 56} 57 58// From converts the unit into the receiver. From returns an 59// error if there is a mismatch in dimension 60func (i *Inductance) From(u Uniter) error { 61 if !DimensionsMatch(u, Henry) { 62 *i = Inductance(math.NaN()) 63 return errors.New("Dimension mismatch") 64 } 65 *i = Inductance(u.Unit().Value()) 66 return nil 67} 68 69func (i Inductance) Format(fs fmt.State, c rune) { 70 switch c { 71 case 'v': 72 if fs.Flag('#') { 73 fmt.Fprintf(fs, "%T(%v)", i, float64(i)) 74 return 75 } 76 fallthrough 77 case 'e', 'E', 'f', 'F', 'g', 'G': 78 p, pOk := fs.Precision() 79 w, wOk := fs.Width() 80 const unit = " H" 81 switch { 82 case pOk && wOk: 83 fmt.Fprintf(fs, "%*.*"+string(c), pos(w-utf8.RuneCount([]byte(unit))), p, float64(i)) 84 case pOk: 85 fmt.Fprintf(fs, "%.*"+string(c), p, float64(i)) 86 case wOk: 87 fmt.Fprintf(fs, "%*"+string(c), pos(w-utf8.RuneCount([]byte(unit))), float64(i)) 88 default: 89 fmt.Fprintf(fs, "%"+string(c), float64(i)) 90 } 91 fmt.Fprint(fs, unit) 92 default: 93 fmt.Fprintf(fs, "%%!%c(%T=%g H)", c, i, float64(i)) 94 } 95} 96