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

93 lines
1.3 KiB
V
Raw Normal View History

2020-02-03 07:00:36 +03:00
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
2019-09-14 23:48:30 +03:00
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module builtin
#include <float.h>
#include <math.h>
pub fn (d f64) str() string {
return '0'
}
pub fn (d f32) str() string {
return '0'
}
pub fn ptr_str(ptr voidptr) string {
return '0'
}
// compare floats using C epsilon
pub fn (a f64) eq(b f64) bool {
//return C.fabs(a - b) <= C.DBL_EPSILON
return (a - b) <= 0.01
}
// fn (nn i32) str() string {
// return i
// }
pub fn (nn int) str() string {
return '0'
}
pub fn (nn u32) str() string {
return '0'
}
pub fn (nn i64) str() string {
return '0'
}
pub fn (nn u64) str() string {
return '0'
}
pub fn (b bool) str() string {
if b {
return 'true'
}
return 'false'
}
pub fn (n int) hex() string {
return '0'
}
pub fn (n i64) hex() string {
return '0'
}
pub fn (a []byte) contains(val byte) bool {
for aa in a {
if aa == val {
return true
}
}
return false
}
pub fn (c rune) str() string {
return '0'
}
pub fn (c byte) str() string {
return '0'
}
pub fn (c byte) is_capital() bool {
return c >= `A` && c <= `Z`
}
pub fn (b []byte) clone() []byte {
2019-09-19 05:22:24 +03:00
mut res := [byte(0)].repeat(b.len)
for i in 0..b.len {
2019-09-14 23:48:30 +03:00
res[i] = b[i]
}
return res
}