String implements fmt.Stringer
()
| 372 | |
| 373 | // String implements fmt.Stringer |
| 374 | func (n *Number) String() string { |
| 375 | switch n.typ { |
| 376 | case InvalidType: |
| 377 | return "0" |
| 378 | case Float32Type, Float64Type: |
| 379 | f, _ := n.Float() |
| 380 | return strconv.FormatFloat(f, 'f', -1, 64) |
| 381 | case IntType: |
| 382 | i, _ := n.Int() |
| 383 | return strconv.FormatInt(i, 10) |
| 384 | case UintType: |
| 385 | u, _ := n.Uint() |
| 386 | return strconv.FormatUint(u, 10) |
| 387 | default: |
| 388 | panic("(*Number).typ is invalid") |
| 389 | } |
| 390 | } |