1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

int.v: fix hex()

This commit is contained in:
Alexander Medvednikov 2019-06-28 15:50:06 +02:00
parent 4cd48a6e18
commit 8abc461a55

View File

@ -124,16 +124,16 @@ pub fn (b bool) str() string {
pub fn (n int) hex() string { pub fn (n int) hex() string {
s := n.str() s := n.str()
hex := malloc(s.len + 2) hex := malloc(s.len + 3) // 0x + \n
C.sprintf(hex, '0x%x', n) C.sprintf(hex, '0x%x', n)
return tos(hex, s.len + 2) return tos(hex, s.len + 3)
} }
pub fn (n i64) hex() string { pub fn (n i64) hex() string {
s := n.str() s := n.str()
hex := malloc(s.len + 2) hex := malloc(s.len + 3)
C.sprintf(hex, '0x%x', n) C.sprintf(hex, '0x%x', n)
return tos(hex, s.len + 2) return tos(hex, s.len + 3)
} }
pub fn (a[]byte) contains(val byte) bool { pub fn (a[]byte) contains(val byte) bool {