You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev_faqs.md
+25-27Lines changed: 25 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ limitations under the License.
33
33
-[I am facing a `Shadowed declaration` linting error in my C files, how can I fix it?](#shadowed-declaration)
34
34
-[I am facing a `Uninitialized variable` linting error in my C files, how can I fix it?](#uninitialized-variable)
35
35
-[I have the required packages in the expected paths, but I am still encountering an error like this while compiling the native add-on.](#compilation-error)
36
+
-[When should I use decimals in examples, benchmarks, and documentation, and when should I avoid them?](#decimal-usage)
36
37
-[How should I name my pull request?](#pr-naming)
37
38
-[How do I call the stdlib bot on my PR?](#stdlib-bot)
38
39
-[Frequently used `make` commands](#freq-make-commands)
@@ -160,33 +161,6 @@ You can suppress that warning by adding a `// cppcheck-suppress uninitvar` comme
## When to use decimals while writing examples, benchmarks and documentation and when should I avoid it?
166
-
167
-
Decimals are our way of showing that the number that we're trying to denote is a floating point value in C. Note that all numbers in JavaScript are treated as a floating point value. for example:
var x =newFloat64Array( [ 1.0, -2.0, NaN, 2.0 ] );
182
-
183
-
var v =dnanvariancetk( 4, 1.0, x, 1 );
184
-
// returns ~4.33333
185
-
```
186
-
187
-
<!--- TODO - complete this and proof read--->
188
-
notice how we used `1.0` in the second arguement because it is a double precision floating point number, while we didn't use it in the first and fourth arguements as they are integers
189
-
190
164
<a name="compilation-error"></a>
191
165
192
166
## I have the required packages in the expected paths, but I am still encountering an error like this while compiling the native add-on.
@@ -252,6 +226,30 @@ In packages involving C implementations, you need a `manifest.json` file to info
252
226
253
227
This `config` specifies that we need to include `@stdlib/math/base/napi/unary`, `@stdlib/math/base/assert/is-nanf`, and `@stdlib/constants/float32/pinf` for compiling the native add-on, while `@stdlib/math/base/assert/is-nanf` and `@stdlib/constants/float32/pinf` are required for running benchmarks and examples.
254
228
229
+
<aname="decimal-usage"></a>
230
+
231
+
## When should I use decimals in examples, benchmarks, and documentation, and when should I avoid them?
232
+
233
+
Decimals help us differentiate floating-point values from integers. For instance, in JavaScript, all numbers are treated as floating-point values, but it is still important to distinguish between integers and floating-point numbers for clarity. Consider the following C function:
When calling this function in JavaScript, we expect the following usage:
240
+
241
+
```javascript
242
+
var dnanvariancetk = require( '@stdlib/stats/base/dnanvariancetk' );
243
+
var Float64Array = require( '@stdlib/array/float64' );
244
+
245
+
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
246
+
247
+
// Use decimals for floating-point values, not for integers.
248
+
var v = dnanvariancetk( 4, 1.0, x, 1 );
249
+
```
250
+
251
+
Notice that we used `1.0` as the second argument because it is a double-precision floating-point number. However, we did not use a decimal point for the first and fourth arguments, as they represent integers.
0 commit comments