Skip to content

[doc-core:math] Documentation for core:math package. (partials) #4961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
78669f4
initial doc for math. Add doc for `Float_class` enum and `sqrt` proce…
kelreeeeey Mar 23, 2025
ba51224
add example for `math.sqrt`
kelreeeeey Mar 23, 2025
d15d6b5
[doc-core:math] added input output in `math.sqrt` procedure group
kelreeeeey Mar 23, 2025
17ffcbd
[doc-core:math] added doc for `math.sin`, `math.cos`, and `math.tan` …
kelreeeeey Mar 23, 2025
449e8bf
Merge branch 'odin-lang:master' into master
kelreeeeey Mar 23, 2025
ab4270e
[doc-core:math] added doc for `math.to_radians` and `math.to_degrees`…
kelreeeeey Mar 23, 2025
9d4ee04
[doc-core:math] fix typo in `Float_Class`
kelreeeeey Mar 24, 2025
4a21de5
[doc-core:math] added more example to `math.sqrt` and change their st…
kelreeeeey Mar 24, 2025
0c50e4d
Merge branch 'odin-lang:master' into master
kelreeeeey Mar 24, 2025
c4e93f0
[doc-core:math] update `doc.odin` explained procedure groups accepted…
kelreeeeey Mar 24, 2025
7ed7800
Merge branch 'master' of https://github.com/kelreeeeey/Odin
kelreeeeey Mar 24, 2025
70a37c5
[doc-core:math] update `math.to_degrees`, added more examples for spe…
kelreeeeey Mar 24, 2025
177ad62
[doc-core:math] update `math.to_radians`, added more examples for spe…
kelreeeeey Mar 24, 2025
4af9e1e
[doc-core:math] update `math.tan`, added more examples for special cases
kelreeeeey Mar 24, 2025
ea4fe8c
[doc-core:math] update `math.cos`, added more examples for special cases
kelreeeeey Mar 24, 2025
cf3b50a
[doc-core:math] update `math.sin`, added more examples for special cases
kelreeeeey Mar 24, 2025
b7ad99c
[doc-core:math] fixed multiline comment
kelreeeeey Mar 24, 2025
1edeace
[doc-core:math] fixed multiline comment
kelreeeeey Mar 24, 2025
fc453bf
Merge branch 'odin-lang:master' into master
kelreeeeey Mar 25, 2025
e54a541
[doc-core:math] added doc for `math.asin` proc and update doc.math
kelreeeeey Mar 25, 2025
b9ce613
[doc-core:math] fix typo in doc `math.asin`
kelreeeeey Mar 25, 2025
293e89a
[doc-core:math] remove unnecesary lines in doc `math.asin`
kelreeeeey Mar 25, 2025
884cef0
[doc-core:math] added doc for `math.acos`
kelreeeeey Mar 25, 2025
c6bf715
[doc-core:math] added doc for `math.atan`
kelreeeeey Mar 25, 2025
dac5931
Merge branch 'odin-lang:master' into master
kelreeeeey Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[doc-core:math] added input output in math.sqrt procedure group
  • Loading branch information
kelreeeeey committed Mar 23, 2025
commit d15d6b54af47caed40fe1969a9510fb03b81bb7d
9 changes: 8 additions & 1 deletion core/math/math.odin
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ clamp :: builtin.clamp
@(require_results) sqrt_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(sqrt_f64(f64(x))) }
@(require_results) sqrt_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(sqrt_f64(f64(x))) }
/*
Will return square root of given input.
Return square root of given input.

**Only accept floats**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably also document the behavior for when the input is an inf, nan, a negative zero and possibly subnormal.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that is a good point! I added more examples for the special cases according to Float_Class enum


Inputs:
- x: input value of type floats
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although pkg.odin-lang might do this conversion automatically, you should respect the LSP and wrap inputs and return value names in backticks, like this:

- `x`: Input value.

Also please form a proper sentence when describing inputs and returns of a procedure. Meaning, capitalizing the first letter and putting a period at the end.

You don't have to specify that x in this function is a float, because you already specified this in the Note above. The point of this section is to establish a connection between the function parameters and its description.


Output:
- x: ouput value that with same type of the input

Example:
x_float : = 4.0 ; sqrt_x_float := math.sqrt(x_float) // using default type of f16
x_f16 :f16 = 30.90 ; sqrt_x_f16 := math.sqrt(x_f16)
Expand All @@ -68,6 +74,7 @@ Example:
x_f64le :f64le = 1000.6 ; sqrt_x_f64le := math.sqrt(x_f64le)
x_f64be :f64be = 89.98 ; sqrt_x_f64be := math.sqrt(x_f64be)


Output:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your example doesn't "print" anything, so there's no "output". This is going to be a problem with the documentation tester that runs all examples inside documentation and checks the output. I suggest you reformat these examples to print results. Might help to not focus on types as much as on values.

2 // `f64`
5.559 // `f16`
Expand Down