|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2023 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# divf |
| 22 | + |
| 23 | +> Divide two single-precision floating-point numbers. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var divf = require( '@stdlib/number/float32/base/div' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### divf( x, y ) |
| 44 | + |
| 45 | +Divides two single-precision floating-point numbers. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var v = divf( -1.0, 5.0 ); |
| 49 | +// returns ~-0.2 |
| 50 | + |
| 51 | +v = divf( 2.0, 5.0 ); |
| 52 | +// returns ~0.4 |
| 53 | + |
| 54 | +v = divf( 0.0, 5.0 ); |
| 55 | +// returns 0.0 |
| 56 | + |
| 57 | +v = divf( -0.0, 5.0 ); |
| 58 | +// returns -0.0 |
| 59 | + |
| 60 | +v = divf( NaN, NaN ); |
| 61 | +// returns NaN |
| 62 | +``` |
| 63 | + |
| 64 | +</section> |
| 65 | + |
| 66 | +<!-- /.usage --> |
| 67 | + |
| 68 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 69 | + |
| 70 | +<section class="notes"> |
| 71 | + |
| 72 | +</section> |
| 73 | + |
| 74 | +<!-- /.notes --> |
| 75 | + |
| 76 | +<!-- Package usage examples. --> |
| 77 | + |
| 78 | +<section class="examples"> |
| 79 | + |
| 80 | +## Examples |
| 81 | + |
| 82 | +<!-- eslint no-undef: "error" --> |
| 83 | + |
| 84 | +```javascript |
| 85 | +var rand = require( '@stdlib/random/base/discrete-uniform' ); |
| 86 | +var divf = require( '@stdlib/number/float32/base/div' ); |
| 87 | + |
| 88 | +var x; |
| 89 | +var y; |
| 90 | +var i; |
| 91 | + |
| 92 | +for ( i = 0; i < 100; i++ ) { |
| 93 | + x = rand( -50, 50 ); |
| 94 | + y = rand( -50, 50 ); |
| 95 | + console.log( '%d / %d = %d', x, y, divf( x, y ) ); |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +</section> |
| 100 | + |
| 101 | +<!-- /.examples --> |
| 102 | + |
| 103 | +<!-- C interface documentation. --> |
| 104 | + |
| 105 | +* * * |
| 106 | + |
| 107 | +<section class="c"> |
| 108 | + |
| 109 | +## C APIs |
| 110 | + |
| 111 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 112 | + |
| 113 | +<section class="intro"> |
| 114 | + |
| 115 | +</section> |
| 116 | + |
| 117 | +<!-- /.intro --> |
| 118 | + |
| 119 | +<!-- C usage documentation. --> |
| 120 | + |
| 121 | +<section class="usage"> |
| 122 | + |
| 123 | +### Usage |
| 124 | + |
| 125 | +```c |
| 126 | +#include "stdlib/number/float32/base/div.h" |
| 127 | +``` |
| 128 | + |
| 129 | +#### stdlib_base_float32_div( x, y ) |
| 130 | + |
| 131 | +Divides two single-precision floating-point numbers. |
| 132 | + |
| 133 | +```c |
| 134 | +float v = stdlib_base_float32_div( -5.0f, 2.0f ); |
| 135 | +// returns -2.5f |
| 136 | +``` |
| 137 | + |
| 138 | +The function accepts the following arguments: |
| 139 | + |
| 140 | +- **x**: `[in] float` first input value (dividend). |
| 141 | +- **y**: `[in] float` second input value (divisor). |
| 142 | + |
| 143 | +```c |
| 144 | +float stdlib_base_float32_div( const float x, const float y ); |
| 145 | +``` |
| 146 | +
|
| 147 | +</section> |
| 148 | +
|
| 149 | +<!-- /.usage --> |
| 150 | +
|
| 151 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 152 | +
|
| 153 | +<section class="notes"> |
| 154 | +
|
| 155 | +</section> |
| 156 | +
|
| 157 | +<!-- /.notes --> |
| 158 | +
|
| 159 | +<!-- C API usage examples. --> |
| 160 | +
|
| 161 | +<section class="examples"> |
| 162 | +
|
| 163 | +### Examples |
| 164 | +
|
| 165 | +```c |
| 166 | +#include "stdlib/number/float32/base/div.h" |
| 167 | +#include <stdio.h> |
| 168 | +
|
| 169 | +int main( void ) { |
| 170 | + const float x[] = { 3.14f, -3.14f, 0.0f, 0.0f/0.0f }; |
| 171 | + const float y[] = { 3.14f, -3.14f, -5.0f, 0.0f/0.0f }; |
| 172 | +
|
| 173 | + float z; |
| 174 | + int i; |
| 175 | + for ( i = 0; i < 4; i++ ) { |
| 176 | + z = stdlib_base_float32_div( x[ i ], y[ i ] ); |
| 177 | + printf( "%f / %f = %f\n", x[ i ], y[ i ], z ); |
| 178 | + } |
| 179 | +} |
| 180 | +``` |
| 181 | + |
| 182 | +</section> |
| 183 | + |
| 184 | +<!-- /.examples --> |
| 185 | + |
| 186 | +</section> |
| 187 | + |
| 188 | +<!-- /.c --> |
| 189 | + |
| 190 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 191 | + |
| 192 | +<section class="related"> |
| 193 | + |
| 194 | +* * * |
| 195 | + |
| 196 | +## See Also |
| 197 | + |
| 198 | +- <span class="package-name">[`@stdlib/number/float32/base/add`][@stdlib/number/float32/base/add]</span><span class="delimiter">: </span><span class="description">compute the sum of two single-precision floating-point numbers.</span> |
| 199 | +- <span class="package-name">[`@stdlib/number/float64/base/div`][@stdlib/number/float64/base/div]</span><span class="delimiter">: </span><span class="description">divide two double-precision floating-point numbers.</span> |
| 200 | +- <span class="package-name">[`@stdlib/math/base/ops/mulf`][@stdlib/math/base/ops/mulf]</span><span class="delimiter">: </span><span class="description">multiply two single-precision floating-point numbers.</span> |
| 201 | +- <span class="package-name">[`@stdlib/math/base/ops/subf`][@stdlib/math/base/ops/subf]</span><span class="delimiter">: </span><span class="description">subtract two single-precision floating-point numbers.</span> |
| 202 | + |
| 203 | +</section> |
| 204 | + |
| 205 | +<!-- /.related --> |
| 206 | + |
| 207 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 208 | + |
| 209 | +<section class="links"> |
| 210 | + |
| 211 | +<!-- <related-links> --> |
| 212 | + |
| 213 | +[@stdlib/number/float32/base/add]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/number/float32/base/add |
| 214 | + |
| 215 | +[@stdlib/number/float64/base/div]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/number/float64/base/div |
| 216 | + |
| 217 | +[@stdlib/math/base/ops/mulf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/ops/mulf |
| 218 | + |
| 219 | +[@stdlib/math/base/ops/subf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/ops/subf |
| 220 | + |
| 221 | +<!-- </related-links> --> |
| 222 | + |
| 223 | +</section> |
| 224 | + |
| 225 | +<!-- /.links --> |
0 commit comments