当前位置: 首页>>代码示例>>Golang>>正文


Golang strconv.Uitoa64函数代码示例

本文整理汇总了Golang中strconv.Uitoa64函数的典型用法代码示例。如果您正苦于以下问题:Golang Uitoa64函数的具体用法?Golang Uitoa64怎么用?Golang Uitoa64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Uitoa64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	limit := uint64(100000000)
	square_sums := []uint64{}
	for i := uint64(0); i < limit; i++ {
		square_sums = append(square_sums, (uint64)(i*(i+1)*(2*i+1)/6))
		if i*i > limit {
			break
		}
	}
	palins := []uint64{}
	for i := 0; i < len(square_sums); i++ {
		for j := 0; j < i; j++ {
			sq_sum := square_sums[i] - square_sums[j]
			if i-j > 1 && sq_sum < limit && strconv.Uitoa64(sq_sum) == Reverse(strconv.Uitoa64(sq_sum)) {
				exists := false
				for k := 0; k < len(palins); k++ {
					if palins[k] == sq_sum {
						exists = true
					}
				}
				if !exists {
					palins = append(palins, sq_sum)
				}
			}
		}
	}
	sum := uint64(0)
	for _, palin := range palins {
		sum += palin
	}
	fmt.Println(sum)
}
开发者ID:smilliken,项目名称:projecteuler,代码行数:32,代码来源:solution125.go

示例2: valueToString

func valueToString(v reflect.Value) (string, os.Error) {
	if v == nil {
		return "null", nil
	}

	switch v := v.(type) {
	case *reflect.PtrValue:
		return valueToString(reflect.Indirect(v))
	case *reflect.InterfaceValue:
		return valueToString(v.Elem())
	case *reflect.BoolValue:
		x := v.Get()
		if x {
			return "true", nil
		} else {
			return "false", nil
		}

	case *reflect.IntValue:
		return strconv.Itoa(v.Get()), nil
	case *reflect.Int8Value:
		return strconv.Itoa(int(v.Get())), nil
	case *reflect.Int16Value:
		return strconv.Itoa(int(v.Get())), nil
	case *reflect.Int32Value:
		return strconv.Itoa(int(v.Get())), nil
	case *reflect.Int64Value:
		return strconv.Itoa64(v.Get()), nil

	case *reflect.UintValue:
		return strconv.Uitoa(v.Get()), nil
	case *reflect.Uint8Value:
		return strconv.Uitoa(uint(v.Get())), nil
	case *reflect.Uint16Value:
		return strconv.Uitoa(uint(v.Get())), nil
	case *reflect.Uint32Value:
		return strconv.Uitoa(uint(v.Get())), nil
	case *reflect.Uint64Value:
		return strconv.Uitoa64(v.Get()), nil
	case *reflect.UintptrValue:
		return strconv.Uitoa64(uint64(v.Get())), nil

	case *reflect.FloatValue:
		return strconv.Ftoa(v.Get(), 'g', -1), nil
	case *reflect.Float32Value:
		return strconv.Ftoa32(v.Get(), 'g', -1), nil
	case *reflect.Float64Value:
		return strconv.Ftoa64(v.Get(), 'g', -1), nil

	case *reflect.StringValue:
		return v.Get(), nil
	case *reflect.SliceValue:
		typ := v.Type().(*reflect.SliceType)
		if _, ok := typ.Elem().(*reflect.Uint8Type); ok {
			return string(v.Interface().([]byte)), nil
		}
	}
	return "", os.NewError("Unsupported type")
}
开发者ID:mikelikespie,项目名称:redis.go,代码行数:59,代码来源:redis.go

示例3: module

func module(f string) (string, os.Error) {
	i, err := os.Stat(f)
	if err != nil {
		return "", err
	}

	m := "$" + f + "-" + strconv.Uitoa64(i.Dev) + "-" +
		strconv.Uitoa64(i.Ino) + "-" + strconv.Itoa64(i.Blocks) + "-" +
		strconv.Itoa64(i.Mtime_ns)

	return m, nil
}
开发者ID:machinaut,项目名称:oh,代码行数:12,代码来源:engine.go

示例4: formatReflectValue

func formatReflectValue(x reflect.Value) (string, os.Error) {
	/*
	   if !x.CanSet() {
	       return "", ErrorCantSet
	   }
	*/
	var (
		errc os.Error
		kind = x.Kind()
		//vintstr   string
	)
	switch kind {
	// Format pointers to standard types.
	case reflect.String:
		return x.Interface().(string), nil
	case reflect.Int:
		return strconv.Itoa(x.Interface().(int)), nil
	case reflect.Int8:
		return strconv.Itoa64(int64(x.Interface().(int8))), nil
	case reflect.Int16:
		return strconv.Itoa64(int64(x.Interface().(int16))), nil
	case reflect.Int32:
		return strconv.Itoa64(int64(x.Interface().(int32))), nil
	case reflect.Int64:
		return strconv.Itoa64(x.Interface().(int64)), nil
	case reflect.Uint:
		return strconv.Uitoa(x.Interface().(uint)), nil
	case reflect.Uint8:
		return strconv.Uitoa64(uint64(x.Interface().(uint8))), nil
	case reflect.Uint16:
		return strconv.Uitoa64(uint64(x.Interface().(uint16))), nil
	case reflect.Uint32:
		return strconv.Uitoa64(uint64(x.Interface().(uint32))), nil
	case reflect.Uint64:
		return strconv.Uitoa64(x.Interface().(uint64)), nil
	case reflect.Float32:
		return strconv.Ftoa32(x.Interface().(float32), FloatFmt, FloatPrec), nil
	case reflect.Float64:
		return strconv.Ftoa64(x.Interface().(float64), FloatFmt, FloatPrec), nil
	case reflect.Complex64:
		fallthrough
	case reflect.Complex128:
		errc = ErrorUnimplemented
	case reflect.Bool:
		return strconv.Btoa(x.Interface().(bool)), nil
	default:
		errc = ErrorFieldType
	}
	return "", errc
}
开发者ID:newblue,项目名称:csvutil,代码行数:50,代码来源:row.go

示例5: Incr

func (self *MapCacheStorage) Incr(key string, value uint64, incr bool) (ErrorCode, *StorageEntry, *StorageEntry) {
	self.rwLock.Lock()
	defer self.rwLock.Unlock()
	entry, present := self.storageMap[key]
	if present && !entry.expired() {
		if addValue, err := strconv.Atoui64(string(entry.content)); err == nil {
			var incrValue uint64
			if incr {
				incrValue = uint64(addValue) + value
			} else if value > addValue {
				incrValue = 0
			} else {
				incrValue = uint64(addValue) - value
			}
			incrStrValue := strconv.Uitoa64(incrValue)
			old_value := entry.content
			entry.content = []byte(incrStrValue)
			entry.bytes = uint32(len(entry.content))
			entry.cas_unique += 1
			return Ok, &StorageEntry{entry.exptime, entry.flags, entry.bytes, entry.cas_unique, old_value}, entry
		} else {
			return IllegalParameter, nil, nil
		}
	}
	return KeyNotFound, nil, nil
}
开发者ID:rdarder,项目名称:gocached,代码行数:26,代码来源:mapcachestorage.go

示例6: atos

// any to string
func atos(i interface{}) (s string) {
	switch t := i.(type) {
	case int64:
		s = strconv.Itoa64(t)
	case uint64:
		s = strconv.Uitoa64(t)
	case float32:
		s = strconv.Ftoa32(t, 'f', -1)
	case float64:
		s = strconv.Ftoa64(t, 'f', -1)
	case []byte:
		s = string(t)
	case Date:
		return t.String()
	case Time:
		return t.String()
	case DateTime:
		return t.String()
	case string:
		return t
	default:
		panic("Not a string or compatible type")
	}
	return
}
开发者ID:sudheesh001,项目名称:nodejs,代码行数:26,代码来源:convert.go

示例7: reseed

func (f *Fortuna) reseed() {
	logTrace("--> F.reseed()")
	// on the n-th reseeding, pool k is used only if 2**k divides n
	f.timesSeeded++
	logDebug("F.reseed(): timesSeeded = " + strconv.Uitoa64(f.timesSeeded))
	f.lock.Lock()
	for k := 0; k < 32; k++ {
		if f.timesSeeded%(1<<uint64(k)) == 0 {
			poolBytes := f.pools[k].Sum()
			f.generator.md.Write(poolBytes)
		}
	}
	f.lock.Unlock()
	f.generator.reseed()
	f.pool0Count = 0
	f.timeLastSeeded = currentTimeMillis()
	if f.timesSeeded == 1 {
		logInfo("F.reseed(): Fortuna is ready and able...")
	}
	// IMPLEMENTATION NOTE (rsn) - we're supposed to save the random seed
	// just before a shutdown.  since we cannot do that in Go we opt for
	// saving it every 10 minutes and every 1000 reseedings.
	if f.timesSeeded%timesSeededPeriod == 0 {
		go updateSeedFile(f)
	}
	logTrace("<-- F.reseed()")
}
开发者ID:welterde,项目名称:crypto-fortuna,代码行数:27,代码来源:prng.go

示例8: enc

func enc(val reflect.Value, typ reflect.Type, buffer *bytes.Buffer, req bool) (encoded bool, err os.Error) {
	switch typ.(type) {
	case *reflect.PtrType:
		// log.Println("pointer")
		pt := typ.(*reflect.PtrType).Elem()
		pv := reflect.Indirect(val)
		// log.Println("Type is: ", pt.Name())
		if pv == nil {
			if !req {
				return false, nil
			} else {
				return false, os.NewError("Required field is nil")
			}
		}
		return enc(pv, pt, buffer, req)
	case *reflect.BoolType:
		if val.(*reflect.BoolValue).Get() {
			buffer.WriteString("true")
		} else {
			buffer.WriteString("false")
		}
	case *reflect.IntType:
		buffer.WriteString(strconv.Itoa64(val.(*reflect.IntValue).Get()))
	case *reflect.UintType:
		buffer.WriteString(strconv.Uitoa64(val.(*reflect.UintValue).Get()))
	case *reflect.StringType:
		buffer.WriteString("\"")
		// TODO: encode
		buffer.WriteString(val.(*reflect.StringValue).Get())
		buffer.WriteString("\"")
	case *reflect.FloatType:
		buffer.WriteString(strconv.Ftoa64(val.(*reflect.FloatValue).Get(), 'e', -1))
	case *reflect.StructType:
		enc_struct(val.(*reflect.StructValue), typ.(*reflect.StructType), buffer)
	case *reflect.SliceType:
		st := typ.(*reflect.SliceType).Elem()
		sv := val.(*reflect.SliceValue)
		if sv.IsNil() {
			if req {
				return false, os.NewError("Required field is nil")
			} else {
				return false, nil
			}
		}
		buffer.WriteString("[")
		for i := 0; i < sv.Len(); i++ {
			if i > 0 {
				buffer.WriteString(",")
			}
			_, err := enc(sv.Elem(i), st, buffer, true)
			if err != nil {
				return false, err
			}
		}
		buffer.WriteString("]")
	default:
		return false, os.NewError("Unsupported type")
	}
	return true, nil
}
开发者ID:AaronO,项目名称:lightwave,代码行数:60,代码来源:jsonprotobuf.go

示例9: AsString

func AsString(v interface{}) (string, os.Error) {
	switch value := v.(type) {
	default:
		return "", os.NewError(fmt.Sprintf("unexpected type: %T", value))
	case int:
		return strconv.Itoa(value), nil
	case int8:
		return strconv.Itoa(int(value)), nil
	case int16:
		return strconv.Itoa(int(value)), nil
	case int32:
		return strconv.Itoa(int(value)), nil
	case int64:
		return strconv.Itoa64(value), nil
	case uint:
		return strconv.Uitoa(value), nil
	case uint8:
		return strconv.Uitoa(uint(value)), nil
	case uint16:
		return strconv.Uitoa(uint(value)), nil
	case uint32:
		return strconv.Uitoa(uint(value)), nil
	case uint64:
		return strconv.Uitoa64(value), nil
	case float32:
		return strconv.Ftoa32(value, 'g', -1), nil
	case float64:
		return strconv.Ftoa64(value, 'g', -1), nil
	case string:
		return value, nil
	}
	panic(fmt.Sprintf("unsupported type: %s", reflect.ValueOf(v).Type().Name()))
}
开发者ID:thomaslee,项目名称:go-ext,代码行数:33,代码来源:conversions.go

示例10: valueToString

func valueToString(v reflect.Value) (string, os.Error) {
	if v == nil {
		return "null", nil
	}

	switch v := v.(type) {
	case *reflect.PtrValue:
		return valueToString(reflect.Indirect(v))
	case *reflect.InterfaceValue:
		return valueToString(v.Elem())
	case *reflect.BoolValue:
		x := v.Get()
		if x {
			return "true", nil
		} else {
			return "false", nil
		}

	case *reflect.IntValue:
		return strconv.Itoa64(v.Get()), nil
	case *reflect.UintValue:
		return strconv.Uitoa64(v.Get()), nil
	case *reflect.UnsafePointerValue:
		return strconv.Uitoa64(uint64(v.Get())), nil

	case *reflect.FloatValue:
		return strconv.Ftoa64(v.Get(), 'g', -1), nil

	case *reflect.StringValue:
		return v.Get(), nil

	//This is kind of a rough hack to replace the old []byte
	//detection with reflect.Uint8Type, it doesn't catch
	//zero-length byte slices
	case *reflect.SliceValue:
		typ := v.Type().(*reflect.SliceType)
		if _, ok := typ.Elem().(*reflect.UintType); ok {
			if v.Len() > 0 {
				if v.Elem(1).(*reflect.UintValue).Overflow(257) {
					return string(v.Interface().([]byte)), nil
				}
			}
		}
	}
	return "", os.NewError("Unsupported type")
}
开发者ID:wladh,项目名称:redis.go,代码行数:46,代码来源:redis.go

示例11: valueToString

func valueToString(v reflect.Value) (string, os.Error) {
	if !v.IsValid() {
		return "null", nil
	}

	switch v.Kind() {
	case reflect.Ptr:
		return valueToString(reflect.Indirect(v))
	case reflect.Interface:
		return valueToString(v.Elem())
	case reflect.Bool:
		x := v.Bool()
		if x {
			return "true", nil
		} else {
			return "false", nil
		}

	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return strconv.Itoa64(v.Int()), nil
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		return strconv.Uitoa64(v.Uint()), nil
	case reflect.UnsafePointer:
		return strconv.Uitoa64(uint64(v.Pointer())), nil

	case reflect.Float32, reflect.Float64:
		return strconv.Ftoa64(v.Float(), 'g', -1), nil

	case reflect.String:
		return v.String(), nil

	//This is kind of a rough hack to replace the old []byte
	//detection with reflect.Uint8Type, it doesn't catch
	//zero-length byte slices
	case reflect.Slice:
		typ := v.Type()
		if typ.Elem().Kind() == reflect.Uint || typ.Elem().Kind() == reflect.Uint8 || typ.Elem().Kind() == reflect.Uint16 || typ.Elem().Kind() == reflect.Uint32 || typ.Elem().Kind() == reflect.Uint64 || typ.Elem().Kind() == reflect.Uintptr {
			if v.Len() > 0 {
				if v.Index(1).OverflowUint(257) {
					return string(v.Interface().([]byte)), nil
				}
			}
		}
	}
	return "", os.NewError("Unsupported type")
}
开发者ID:alangenfeld,项目名称:flock,代码行数:46,代码来源:redis.go

示例12: printPresent

func (sh *serverHeap) printPresent() string {
	var out string = ""
	cnt := sh.vec.Len()
	for i := 0; i < cnt; i++ {
		s := sh.vec.At(i).(*server)
		out += "\ts.id: " + strconv.Uitoa64(s.id) + " addr: " + fmt.Sprintf("%s:%d", s.addr.IP.String(), s.addr.Port) + " nchunks: " + strconv.Itoa(s.chunks.Len()) + " chunks: "

		cnt2 := s.chunks.Len()
		for j := 0; j < cnt2; j++ {
			out += strconv.Uitoa64(s.chunks.At(j).(*chunk).chunkID) + ", "
		}

		out += "\n"
	}

	//log.Printf("master: server heap state follows:\n%s", out)
	return out
}
开发者ID:alangenfeld,项目名称:cs639,代码行数:18,代码来源:serverHeap.go

示例13: main

func main() {
	flag.Parse()
	fmt.Println("Consuming Messages :")
	fmt.Printf("From: %s, topic: %s, partition: %d\n", hostname, topic, partition)
	fmt.Println(" ---------------------- ")
	broker := kafka.NewBrokerConsumer(hostname, topic, partition, offset, uint32(maxSize))

	var payloadFile *os.File = nil
	if len(writePayloadsTo) > 0 {
		var err os.Error
		payloadFile, err = os.Create(writePayloadsTo)
		if err != nil {
			fmt.Println("Error opening file: ", err)
			payloadFile = nil
		}
	}

	consumerCallback := func(msg *kafka.Message) {
		if printmessage {
			msg.Print()
		}
		if payloadFile != nil {
			payloadFile.Write([]byte("Message at: " + strconv.Uitoa64(msg.Offset()) + "\n"))
			payloadFile.Write(msg.Payload())
			payloadFile.Write([]byte("\n-------------------------------\n"))
		}
	}

	if consumerForever {
		quit := make(chan bool, 1)
		go func() {
			for {
				sig := <-signal.Incoming
				if sig.(signal.UnixSignal) == syscall.SIGINT {
					quit <- true
				}
			}
		}()

		msgChan := make(chan *kafka.Message)
		go broker.ConsumeOnChannel(msgChan, 10, quit)
		for msg := range msgChan {
			if msg != nil {
				consumerCallback(msg)
			} else {
				break
			}
		}
	} else {
		broker.Consume(consumerCallback)
	}

	if payloadFile != nil {
		payloadFile.Close()
	}

}
开发者ID:Bny12,项目名称:kafka,代码行数:57,代码来源:consumer.go

示例14: updatePrefix

// Update the prefix on a membership entry.
func (p *ModeParser) updatePrefix(m *core.Membership) {
	var prefix string
	for it := p.prefixes; it != nil; it = it.next {
		if m.Data(it.metadata) != "" {
			prefix += string(it.prefix)
		}
	}
	m.SetData("", nil, strconv.Uitoa64(p.id)+" prefixes", prefix)
}
开发者ID:jbeshir,项目名称:OddComm,代码行数:10,代码来源:modeprefixes.go

示例15: stringName

func stringName(i uint32, names []intName, goSyntax bool) string {
	for _, n := range names {
		if n.i == i {
			if goSyntax {
				return "macho." + n.s
			}
			return n.s
		}
	}
	return strconv.Uitoa64(uint64(i))
}
开发者ID:rapgamer,项目名称:golang-china,代码行数:11,代码来源:macho.go


注:本文中的strconv.Uitoa64函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。