mirror of
				https://github.com/aykhans/dodo.git
				synced 2025-11-03 22:19:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			230 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			230 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package utils
 | 
						|
 | 
						|
type Number interface {
 | 
						|
	int | int8 | int16 | int32 | int64
 | 
						|
}
 | 
						|
 | 
						|
func NumLen[T Number](n T) T {
 | 
						|
	if n < 0 {
 | 
						|
		n = -n
 | 
						|
	}
 | 
						|
	if n == 0 {
 | 
						|
		return 1
 | 
						|
	}
 | 
						|
 | 
						|
	var count T = 0
 | 
						|
	for n > 0 {
 | 
						|
		n /= 10
 | 
						|
		count++
 | 
						|
	}
 | 
						|
	return count
 | 
						|
}
 |