Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

v0.8.0

Choose a tag to compare

@HelloAIXIAOJI HelloAIXIAOJI released this 09 Aug 17:56
· 337 commits to master since this release

[v0.8.0] - 2025-08-10 - Major Update Version of Extended Math Library

🧮 Extended Math Library

🎯 Core Features: Comprehensive Mathematical Computing Platform

Implemented a complete mathematical library for the CodeNothing language, expanding from 21 functions in the base version to 51 functions, representing a 143% increase in functionality and covering all areas of modern mathematical computation.

📚 Complete Mathematical Function System

  • 8 Namespaces: root namespace, trig, log, constants, hyperbolic, stats, random, numeric
  • 51 Mathematical Functions: Full coverage from basic mathematics to advanced numerical analysis
  • Smart Type System: Automatic type conversion, supporting int, float, string types
  • Error Handling Mechanism: Comprehensive boundary checks and NaN handling

🔧 Basic Mathematical Functions (Root Namespace)

// Basic Operations
result : float = abs("-5.5");          // Absolute value: 5.5
result : float = max("10", "20");       // Maximum value: 20
result : float = min("10", "20");       // Minimum value: 10
result : float = pow("2", "3");         // Exponentiation: 8
result : float = sqrt("16");            // Square root: 4

// Extended functions
result : float = cbrt("8");             // Cube root: 2
result : float = ceil("3.2");           // Ceiling: 4
result : float = floor("3.8");          // Floor: 3
result : float = round("3.6");          // Round: 4
result : float = trunc("3.9");          // Truncate: 3
result : int = sign("-5");              // Sign function: -1

📐 Trigonometric functions (trig namespace)

codenothing
using ns trig;

// Basic trigonometric functions
sin_val : float = sin("1.57"); // Sine value
cos_val : float = cos("0"); // Cosine value: 1
tan_val : float = tan("0.785"); // Tangent value

// Inverse trigonometric functions
asin_val : float = asin("0.5"); // Inverse sine
acos_val : float = acos("0.5"); // Inverse cosine
atan_val : float = atan("1"); // Inverse tangent

// Angle and Radian Conversion
rad_val : float = to_radians("90"); // Angle to Radian
deg_val : float = to_degrees("1.57"); // Radian to Angle


#### 📊 Logarithmic Functions (log namespace)
```codenothing
using ns log;

// Various logarithmic functions
ln_val : float = ln("2.718");           // Natural logarithm
log10_val : float = log10("100");       // Common logarithm: 2
log2_val : float = log2("8");           // Binary logarithm: 3
log_val : float = log("8", "2");        // Logarithm with specified base: 3

🌊 Hyperbolic functions (hyperbolic namespace)

codenothing
using ns hyperbolic;

// Hyperbolic functions
sinh_val : float = sinh("1"); // Hyperbolic sine: 1.175
cosh_val : float = cosh("0"); // Hyperbolic cosine: 1
tanh_val : float = tanh("1"); // Hyperbolic tangent: 0.762

// Hyperbolic inverse functions
asinh_val : float = asinh("1"); // Hyperbolic arcsine
acosh_val : float = acosh("2"); // Hyperbolic arccosine
atanh_val : float = atanh("0.5"); // Hyperbolic arctangent


#### 📈 Statistical Functions (stats namespace)
```codenothing```
using ns stats;

// Descriptive statistics (support multiple parameters)
mean_val : float = mean("1", "2", "3", "4", "5");      // Mean: 3
median_val : float = median("1", "3", "2", "5", "4");  // Median: 3
stddev_val : float = stddev("1", "2", "3", "4", "5");  // Standard deviation
variance_val : float = variance("1", "2", "3", "4", "5"); // variance

🎲 Random Number Generation (random namespace)

using ns random;

// Random number generation system
seed("12345");                          // Set random seed
rand_val : float = random();            // Random float between 0-1
rand_int : int = randint("1", "10");    // Random integer between 1-10
uniform_val : float = uniform("0", "100"); // Random floating-point number between 0-100

🔢 Numeric Analysis (numeric namespace)

using ns numeric;

// Combinatorics
fact_val : int = factorial("5");        // Factorial: 120
comb_val : int = combination("5", "2");  // Combination C(5,2): 10
perm_val : int = permutation("5", "2");  // Permutation P(5,2): 20

// Number theory functions
gcd_val : int = gcd("12", "8");         // Greatest common divisor: 4
lcm_val : int = lcm("12", "8");         // Least common multiple: 24

🔢 Mathematical Constants (constants namespace)

using ns constants;

// Basic constants
pi_val : float = pi();                  // Pi: 3.14159...
e_val : float = e();                    // E: 2.71828...
phi_val : float = phi();                // Golden ratio φ: 1.61803...
sqrt2_val : float = sqrt2();            // Square root of 2: 1.41421...

// Extended constants
euler_gamma_val : float = euler_gamma(); // Euler's constant γ: 0.57721...
frac_1_pi_val : float = frac_1_pi();    // 1/π
frac_2_pi_val : float = frac_2_pi();    // 2/π
ln_2_val : float = ln_2();              // ln(2): 0.69314...
ln_10_val : float = ln_10();            // ln(10): 2.30258...

🧪 Test Validation Results

🧮 Starting Extended Math Library Tests
=====================================
1. Extend basic function tests
cbrt(8) = 2
ceil(3.2) = 4
floor(3.8) = 3
round(3.6) = 4
sign(-5) = -1

2. Hyperbolic function test
sinh(1) = 1.1752011936438014
cosh(0) = 1
tanh(1) = 0.7615941559557649

3. Statistical function test
mean(1,2,3,4,5) = 3
median(1,3,2,5,4) = 3

Numerical Analysis Test
factorial(5) = 120
combination(5, 2) = 10
gcd(12, 8) = 4

5. Random number generation test
Set random seed: 12345
random() = 0.0000007384986563176458
randint(1, 10) = 6

6. Extended constant test
Euler constant γ = 0.5772156649015329
ln(2) = 0.6931471805599453

📈 Results Summary

CodeNothing Math Library has now become:

  • The most comprehensive CodeNothing math library (51 functions, 8 namespaces)
  • Performance Optimization high-efficiency computing platform
  • Comprehensive Documentation user-friendly tool
  • Thoroughly Tested reliable components

This version marks CodeNothing's new milestone in mathematical computing capabilities, providing powerful mathematical computing support for a wide range of application scenarios, from basic education to professional scientific computing!


[v0.8.0] - 2025-08-10 - 扩展数学库重大更新版本

🧮 扩展数学库 (Extended Math Library)

🎯 核心特性:全面的数学计算平台

实现了CodeNothing语言的完整数学库,从基础版本的21个函数扩展到51个函数,功能增长143%,涵盖现代数学计算的各个领域。

📚 完整的数学功能体系

  • 8个命名空间:根命名空间、trig、log、constants、hyperbolic、stats、random、numeric
  • 51个数学函数:从基础数学到高级数值分析的全覆盖
  • 智能类型系统:自动类型转换,支持int、float、string类型
  • 错误处理机制:完善的边界检查和NaN处理

🔧 基础数学函数(根命名空间)

// 基础运算
result : float = abs("-5.5");          // 绝对值: 5.5
result : float = max("10", "20");       // 最大值: 20
result : float = min("10", "20");       // 最小值: 10
result : float = pow("2", "3");         // 幂运算: 8
result : float = sqrt("16");            // 平方根: 4

// 扩展函数
result : float = cbrt("8");             // 立方根: 2
result : float = ceil("3.2");           // 向上取整: 4
result : float = floor("3.8");          // 向下取整: 3
result : float = round("3.6");          // 四舍五入: 4
result : float = trunc("3.9");          // 截断: 3
result : int = sign("-5");              // 符号函数: -1

📐 三角函数(trig命名空间)

using ns trig;

// 基本三角函数
sin_val : float = sin("1.57");          // 正弦值
cos_val : float = cos("0");             // 余弦值: 1
tan_val : float = tan("0.785");         // 正切值

// 反三角函数
asin_val : float = asin("0.5");         // 反正弦
acos_val : float = acos("0.5");         // 反余弦
atan_val : float = atan("1");           // 反正切

// 角度弧度转换
rad_val : float = to_radians("90");     // 角度转弧度
deg_val : float = to_degrees("1.57");   // 弧度转角度

📊 对数函数(log命名空间)

using ns log;

// 各种对数函数
ln_val : float = ln("2.718");           // 自然对数
log10_val : float = log10("100");       // 常用对数: 2
log2_val : float = log2("8");           // 二进制对数: 3
log_val : float = log("8", "2");        // 指定底数对数: 3

🌊 双曲函数(hyperbolic命名空间)

using ns hyperbolic;

// 双曲函数
sinh_val : float = sinh("1");           // 双曲正弦: 1.175
cosh_val : float = cosh("0");           // 双曲余弦: 1
tanh_val : float = tanh("1");           // 双曲正切: 0.762

// 反双曲函数
asinh_val : float = asinh("1");         // 反双曲正弦
acosh_val : float = acosh("2");         // 反双曲余弦
atanh_val : float = atanh("0.5");       // 反双曲正切

📈 统计函数(stats命名空间)

using ns stats;

// 描述性统计(支持多参数)
mean_val : float = mean("1", "2", "3", "4", "5");      // 平均值: 3
median_val : float = median("1", "3", "2", "5", "4");  // 中位数: 3
stddev_val : float = stddev("1", "2", "3", "4", "5");  // 标准差
variance_val : float = variance("1", "2", "3", "4", "5"); // 方差

🎲 随机数生成(random命名空间)

using ns random;

// 随机数生成系统
seed("12345");                          // 设置随机种子
rand_val : float = random();            // 0-1随机浮点数
rand_int : int = randint("1", "10");    // 1-10随机整数
uniform_val : float = uniform("0", "100"); // 0-100随机浮点数

🔢 数值分析(numeric命名空间)

using ns numeric;

// 组合数学
fact_val : int = factorial("5");        // 阶乘: 120
comb_val : int = combination("5", "2");  // 组合数C(5,2): 10
perm_val : int = permutation("5", "2");  // 排列数P(5,2): 20

// 数论函数
gcd_val : int = gcd("12", "8");         // 最大公约数: 4
lcm_val : int = lcm("12", "8");         // 最小公倍数: 24

🔢 数学常数(constants命名空间)

using ns constants;

// 基础常数
pi_val : float = pi();                  // 圆周率π: 3.14159...
e_val : float = e();                    // 自然常数e: 2.71828...
phi_val : float = phi();                // 黄金比例φ: 1.61803...
sqrt2_val : float = sqrt2();            // 2的平方根: 1.41421...

// 扩展常数
euler_gamma_val : float = euler_gamma(); // 欧拉常数γ: 0.57721...
frac_1_pi_val : float = frac_1_pi();    // 1/π
frac_2_pi_val : float = frac_2_pi();    // 2/π
ln_2_val : float = ln_2();              // ln(2): 0.69314...
ln_10_val : float = ln_10();            // ln(10): 2.30258...

🧪 测试验证结果

🧮 扩展Math库测试开始
=====================================
1. 扩展基础函数测试
cbrt(8) = 2
ceil(3.2) = 4
floor(3.8) = 3
round(3.6) = 4
sign(-5) = -1

2. 双曲函数测试
sinh(1) = 1.1752011936438014
cosh(0) = 1
tanh(1) = 0.7615941559557649

3. 统计函数测试
mean(1,2,3,4,5) = 3
median(1,3,2,5,4) = 3

4. 数值分析测试
factorial(5) = 120
combination(5, 2) = 10
gcd(12, 8) = 4

5. 随机数生成测试
设置随机种子: 12345
random() = 0.0000007384986563176458
randint(1, 10) = 6

6. 扩展常数测试
欧拉常数γ = 0.5772156649015329
ln(2) = 0.6931471805599453

📈 成果总结

CodeNothing Math Library现已成为:

  • 功能最全面的CodeNothing数学库(51个函数,8个命名空间)
  • 性能优化的高效计算平台
  • 文档完善的易用工具
  • 测试充分的可靠组件

这个版本标志着CodeNothing在数学计算能力方面达到了新的高度,为从基础教学到专业科学计算的各种应用场景提供了强大的数学计算支持!

Full Changelog: CodeNothingCommunity/CodeNothing@v0.7.7...v0.8.0