mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
check integer const overflow at compilation
This commit is contained in:
@@ -133,6 +133,10 @@ pub fn (s string) int() int {
|
||||
return C.atoi(s.str)
|
||||
}
|
||||
|
||||
pub fn (s string) i64() i64 {
|
||||
return C.atoll(s.str)
|
||||
}
|
||||
|
||||
pub fn (s string) f32() f32 {
|
||||
return C.atof(s.str)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,21 @@ const (
|
||||
Log10E = 1.0 / Ln10
|
||||
)
|
||||
|
||||
const (
|
||||
MaxI8 = (1<<7) - 1
|
||||
MinI8 = -1 << 7
|
||||
MaxI16 = (1<<15) - 1
|
||||
MinI16 = -1 << 15
|
||||
MaxI32 = (1<<31) - 1
|
||||
MinI32 = -1 << 31
|
||||
// MaxI64 = ((1<<63) - 1)
|
||||
// MinI64 = (-(1 << 63) )
|
||||
MaxU8 = (1<<8) - 1
|
||||
MaxU16 = (1<<16) - 1
|
||||
MaxU32 = (1<<32) - 1
|
||||
MaxU64 = (1<<64) - 1
|
||||
)
|
||||
|
||||
// Returns the absolute value.
|
||||
pub fn abs(a f64) f64 {
|
||||
if a < 0 {
|
||||
|
||||
Reference in New Issue
Block a user