feat: add the number package

This commit is contained in:
2025-10-28 17:53:43 +04:00
parent 82197ac9b9
commit c29e082426
3 changed files with 390 additions and 0 deletions

26
number/base.go Normal file
View File

@@ -0,0 +1,26 @@
package number
type Number interface {
int | int8 | int16 | int32 | int64 |
uint | uint8 | uint16 | uint32 | uint64 | uintptr
}
func NumLen[T Number](number T) T {
if number == 0 {
return 1
}
var count T = 0
if number < 0 {
for number < 0 {
number /= 10
count++
}
} else {
for number > 0 {
number /= 10
count++
}
}
return count
}