docs: Add math section to syntax reference + improve example comments
- five-syntax-en/ko: Add Math comparison table (Harbour RTL vs Go math) - go_math_compare.prg: Detailed English comments explaining each section - Example lists updated with go_math_compare.prg Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -384,6 +384,45 @@ dbTarget:Close()
|
||||
20K concurrent goroutines, 5K random fuzz
|
||||
```
|
||||
|
||||
## Math: Harbour RTL + Go math Together
|
||||
|
||||
Five gives you two math systems in one file:
|
||||
|
||||
```prg
|
||||
IMPORT "math"
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL nVal
|
||||
|
||||
// Harbour RTL — simple, no IMPORT needed
|
||||
? Abs(-42.5) // 42.5
|
||||
? Sqrt(144) // 12
|
||||
? Round(3.14159, 2) // 3.14
|
||||
? Max(10, 20) // 20
|
||||
|
||||
// Go math — complete, 60+ functions
|
||||
? math.Sin(math.Pi / 6) // 0.5
|
||||
? math.Pow(2, 10) // 1024
|
||||
? math.Hypot(3, 4) // 5
|
||||
? math.Log2(1024) // 10
|
||||
|
||||
// Combined — use both freely
|
||||
nVal := (1 / Sqrt(2 * math.Pi)) * Exp(-0.5 * math.Pow(0, 2))
|
||||
? "Normal PDF at 0:", Round(nVal, 6)
|
||||
|
||||
RETURN
|
||||
```
|
||||
|
||||
| | Harbour RTL | Go math |
|
||||
|---|---|---|
|
||||
| Functions | 9 (Abs, Sqrt, Round, Int, Max, Min, Log, Exp, Mod) | 60+ |
|
||||
| IMPORT needed | No | `IMPORT "math"` |
|
||||
| Best for | Business calculations | Scientific/financial |
|
||||
| Precision | Standard | IEEE 754 |
|
||||
| Trig/Hyperbolic | No | Sin, Cos, Tan, Sinh, Cosh, ... |
|
||||
| Constants | No | Pi, E, Phi, Ln2, Sqrt2 |
|
||||
| Special values | No | NaN, Inf, MaxFloat64 |
|
||||
|
||||
## Example Files
|
||||
|
||||
| File | Description |
|
||||
@@ -397,4 +436,5 @@ dbTarget:Close()
|
||||
| `examples/go_concurrent.prg` | Parallel data pipeline |
|
||||
| `examples/go_websocket.prg` | WebSocket chat server |
|
||||
| `examples/go_extensions.prg` | All 9 extension syntax demo |
|
||||
| `examples/go_math_compare.prg` | Harbour RTL vs Go math side-by-side |
|
||||
| `examples/godump_demo.prg` | HB_FUNC Go API |
|
||||
|
||||
Reference in New Issue
Block a user