"Fossies" - the Fresh Open Source Software Archive

Member "buildah-1.23.1/vendor/github.com/json-iterator/go/any_float.go" (28 Sep 2021, 1252 Bytes) of package /linux/misc/buildah-1.23.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package jsoniter
    2 
    3 import (
    4     "strconv"
    5 )
    6 
    7 type floatAny struct {
    8     baseAny
    9     val float64
   10 }
   11 
   12 func (any *floatAny) Parse() *Iterator {
   13     return nil
   14 }
   15 
   16 func (any *floatAny) ValueType() ValueType {
   17     return NumberValue
   18 }
   19 
   20 func (any *floatAny) MustBeValid() Any {
   21     return any
   22 }
   23 
   24 func (any *floatAny) LastError() error {
   25     return nil
   26 }
   27 
   28 func (any *floatAny) ToBool() bool {
   29     return any.ToFloat64() != 0
   30 }
   31 
   32 func (any *floatAny) ToInt() int {
   33     return int(any.val)
   34 }
   35 
   36 func (any *floatAny) ToInt32() int32 {
   37     return int32(any.val)
   38 }
   39 
   40 func (any *floatAny) ToInt64() int64 {
   41     return int64(any.val)
   42 }
   43 
   44 func (any *floatAny) ToUint() uint {
   45     if any.val > 0 {
   46         return uint(any.val)
   47     }
   48     return 0
   49 }
   50 
   51 func (any *floatAny) ToUint32() uint32 {
   52     if any.val > 0 {
   53         return uint32(any.val)
   54     }
   55     return 0
   56 }
   57 
   58 func (any *floatAny) ToUint64() uint64 {
   59     if any.val > 0 {
   60         return uint64(any.val)
   61     }
   62     return 0
   63 }
   64 
   65 func (any *floatAny) ToFloat32() float32 {
   66     return float32(any.val)
   67 }
   68 
   69 func (any *floatAny) ToFloat64() float64 {
   70     return any.val
   71 }
   72 
   73 func (any *floatAny) ToString() string {
   74     return strconv.FormatFloat(any.val, 'E', -1, 64)
   75 }
   76 
   77 func (any *floatAny) WriteTo(stream *Stream) {
   78     stream.WriteFloat64(any.val)
   79 }
   80 
   81 func (any *floatAny) GetInterface() interface{} {
   82     return any.val
   83 }