mirror of
				https://github.com/jefferyjob/go-easy-utils.git
				synced 2025-10-31 18:33:21 +08:00 
			
		
		
		
	
							
								
								
									
										17
									
								
								mathUtil/floor.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								mathUtil/floor.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| package mathUtil | ||||
|  | ||||
| import ( | ||||
| 	"math" | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| // Floor 对float数据向下取整 | ||||
| func Floor[T float32 | float64](num T) int { | ||||
| 	switch reflect.ValueOf(num).Kind() { | ||||
| 	case reflect.Float32: | ||||
| 		return int(math.Floor(float64(num))) | ||||
| 	case reflect.Float64: | ||||
| 		return int(math.Floor(float64(num))) | ||||
| 	} | ||||
| 	return 0 | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 jeffery
					jeffery