MariaDB是否有内置函数使用指定的基数获取整数值进行转换?
Have MariaDB built-in function to get the integer value using specified base for the conversion?
MariaDB 是否有内置模拟 PHP intval() or Golang strconv.FormatInt() and strconv.ParseInt() 函数来将 10 位整数值转换为 36 位整数值,反之亦然?
我需要在 MariaDB stored procedure.
中调用这些函数
package main
import (
"fmt"
"strconv"
)
func main() {
var (
i64 int64
str36base string
err error
)
i64 = 99999999999999
str36base = strconv.FormatInt(i64, 36) // from 10-base to 36-base integer
fmt.Printf("10-base integer: %v --> 36-base integer: %v\n", i64, str36base)
i64, err = strconv.ParseInt(str36base, 36, 64) // from 36-base to 10-base integer
if err == nil {
fmt.Printf("36-base integer: %v --> 10-base integer: %v\n", str36base, i64)
} else {
fmt.Println(err.Error())
}
}
Output:
10-base integer: 99999999999999 --> 36-base integer: zg3d62r5r
36-base integer: zg3d62r5r --> 10-base integer: 99999999999999
猜猜你在找 CONV()
?
https://mariadb.com/kb/en/conv/
SELECT CONV(99999999999999, 10, 36) AS `converted` FROM DUAL;
MariaDB 是否有内置模拟 PHP intval() or Golang strconv.FormatInt() and strconv.ParseInt() 函数来将 10 位整数值转换为 36 位整数值,反之亦然? 我需要在 MariaDB stored procedure.
中调用这些函数package main
import (
"fmt"
"strconv"
)
func main() {
var (
i64 int64
str36base string
err error
)
i64 = 99999999999999
str36base = strconv.FormatInt(i64, 36) // from 10-base to 36-base integer
fmt.Printf("10-base integer: %v --> 36-base integer: %v\n", i64, str36base)
i64, err = strconv.ParseInt(str36base, 36, 64) // from 36-base to 10-base integer
if err == nil {
fmt.Printf("36-base integer: %v --> 10-base integer: %v\n", str36base, i64)
} else {
fmt.Println(err.Error())
}
}
Output:
10-base integer: 99999999999999 --> 36-base integer: zg3d62r5r
36-base integer: zg3d62r5r --> 10-base integer: 99999999999999
猜猜你在找 CONV()
?
https://mariadb.com/kb/en/conv/
SELECT CONV(99999999999999, 10, 36) AS `converted` FROM DUAL;