XUtility

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 1 Imported by: 0

README

XUtility

Reference Release Report DeepWiki

XUtility 提供了常用的工具函数集,如数值计算、随机数等。

功能特性

  • 数值计算:提供最大值、最小值计算
  • 随机数生成:支持指定范围的随机整数生成

使用手册

1. 数值计算
1.1 获取最大最小值
// 获取两个数中的最大值
max := XUtility.MaxValue(10, 20) // 返回 20

// 获取两个数中的最小值
min := XUtility.MinValue(10, 20) // 返回 10
2. 随机数生成
2.1 生成指定范围的随机数
// 生成 [1, 100) 范围内的随机数
// 注意:右区间是开区间,不包含 100
rand := XUtility.RandInt(1, 100)

常见问题

1. 随机数范围说明

RandInt 函数生成的随机数范围是左闭右开区间 [min, max),即包含最小值但不包含最大值。例如:

  • RandInt(1, 10) 生成的随机数可能是:1, 2, 3, 4, 5, 6, 7, 8, 9
  • 不会生成 10

项目信息

Documentation

Overview

XUtility 提供了常用的工具函数集,如数值计算、随机数等。

功能特性

  • 数值计算:提供最大值、最小值计算
  • 随机数生成:支持指定范围的随机整数生成

使用示例

1. 数值计算

1.1 获取最大最小值

max := XUtility.MaxValue(10, 20) // 返回 20
min := XUtility.MinValue(10, 20) // 返回 10

2. 随机数生成

2.1 生成指定范围的随机数

// 生成 [1, 100) 范围内的随机数
rand := XUtility.RandInt(1, 100)

更多信息请参考模块文档。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxValue

func MaxValue(a int, b int) int

MaxValue 返回两个整数中的最大值。 a 第一个整数。 b 第二个整数。 返回两个整数中的较大值。

func MinValue

func MinValue(a int, b int) int

MinValue 返回两个整数中的最小值。 a 第一个整数。 b 第二个整数。 返回两个整数中的较小值。

func RandInt

func RandInt(min int, max int) int

RandInt 生成指定范围内的随机整数。 min 最小值(包含)。 max 最大值(不包含)。 返回 [min, max) 范围内的随机整数,如果 min >= max,则返回 max。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL