Skip to content

Commit 2d54309

Browse files
committed
feat: updated Readme file with C implementation
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c38b10b commit 2d54309

File tree

1 file changed

+98
-0
lines changed
  • lib/node_modules/@stdlib/number/float16/base/sub

1 file changed

+98
-0
lines changed

lib/node_modules/@stdlib/number/float16/base/sub/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,104 @@ logEachMap( 'x: %f, y: %f => %f', x, y, sub );
9898

9999
<!-- /.examples -->
100100

101+
<!-- C interface documentation. -->
102+
103+
* * *
104+
105+
<section class="c">
106+
107+
## C APIs
108+
109+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
110+
111+
<section class="intro">
112+
113+
</section>
114+
115+
<!-- /.intro -->
116+
117+
<!-- C usage documentation. -->
118+
119+
<section class="usage">
120+
121+
### Usage
122+
123+
```c
124+
#include "stdlib/number/float16/base/sub.h"
125+
```
126+
127+
#### stdlib_base_float16_mul( x, y )
128+
129+
Subtract two half-precision floating-point numbers.
130+
131+
```c
132+
#include "stdlib/number/float16/ctor.h"
133+
134+
stdlib_float16_t x = stdlib_float16_from_bits( 17664 ); // => 5.0
135+
stdlib_float16_t y = stdlib_float16_from_bits( 16384 ); // => 2.0
136+
137+
stdlib_float16_t v = stdlib_base_float16_sub( x, y );
138+
```
139+
140+
The function accepts the following arguments:
141+
142+
- **x**: `[in] stdlib_float16_t` first input value.
143+
- **y**: `[in] stdlib_float16_t` second input value.
144+
145+
```c
146+
stdlib_float16_t stdlib_base_float16_sub( const stdlib_float16_t x, const stdlib_float16_t y );
147+
```
148+
149+
</section>
150+
151+
<!-- /.usage -->
152+
153+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
154+
155+
<section class="notes">
156+
157+
</section>
158+
159+
<!-- /.notes -->
160+
161+
<!-- C API usage examples. -->
162+
163+
<section class="examples">
164+
165+
### Examples
166+
167+
```c
168+
#include "stdlib/number/float16/base/sub.h"
169+
#include "stdlib/number/float16/ctor.h"
170+
#include "stdlib/number/float32/base/to_float16.h"
171+
#include "stdlib/number/float16/base/to_float32.h"
172+
#include <stdio.h>
173+
174+
int main( void ) {
175+
const float x[] = { 3.14f, -3.14f, 0.0f, 0.0f/0.0f };
176+
const float y[] = { 3.14f, -3.14f, -0.0f, 0.0f/0.0f };
177+
178+
stdlib_float16_t v;
179+
stdlib_float16_t w;
180+
stdlib_float16_t z;
181+
int i;
182+
for ( i = 0; i < 4; i++ ) {
183+
v = stdlib_base_float32_to_float16( x[ i ]);
184+
w = stdlib_base_float32_to_float16( y[ i ]);
185+
z = stdlib_base_float16_sub( v, w );
186+
printf( "%f - %f = %f\n", stdlib_base_float16_to_float32( v ), stdlib_base_float16_to_float32( w ), stdlib_base_float16_to_float32( z ) );
187+
}
188+
}
189+
```
190+
191+
</section>
192+
193+
<!-- /.examples -->
194+
195+
</section>
196+
197+
<!-- /.c -->
198+
101199
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
102200

103201
<section class="related">

0 commit comments

Comments
 (0)