|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2024 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 | +# nanmaxf |
| 22 | + |
| 23 | +> Return the maximum value of two single-precision floating-point numbers, ignoring NaN. |
| 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 nanmaxf = require( '@stdlib/math/base/special/nanmaxf' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### nanmaxf( x, y ) |
| 44 | + |
| 45 | +Returns the maximum value of two single-precision floating-point numbers, ignoring NaN. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var v = nanmaxf( 4.2, 3.14 ); |
| 49 | +// returns 4.2 |
| 50 | + |
| 51 | +v = nanmaxf( +0.0, -0.0 ); |
| 52 | +// returns +0.0 |
| 53 | +``` |
| 54 | + |
| 55 | +If any argument is `NaN`, the function returns the other operand. |
| 56 | + |
| 57 | +```javascript |
| 58 | +var v = nanmaxf( 4.2, NaN ); |
| 59 | +// returns 4.2 |
| 60 | + |
| 61 | +v = nanmaxf( NaN, 3.14 ); |
| 62 | +// returns 3.14 |
| 63 | +``` |
| 64 | + |
| 65 | +If both arguments are `NaN`, the function returns `NaN`. |
| 66 | + |
| 67 | +```javascript |
| 68 | +var v = nanmaxf( NaN, NaN ); |
| 69 | +// returns NaN |
| 70 | +``` |
| 71 | + |
| 72 | +</section> |
| 73 | + |
| 74 | +<!-- /.usage --> |
| 75 | + |
| 76 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 77 | + |
| 78 | +<section class="notes"> |
| 79 | + |
| 80 | +</section> |
| 81 | + |
| 82 | +<!-- /.notes --> |
| 83 | + |
| 84 | +<!-- Package usage examples. --> |
| 85 | + |
| 86 | +<section class="examples"> |
| 87 | + |
| 88 | +## Examples |
| 89 | + |
| 90 | +<!-- eslint no-undef: "error" --> |
| 91 | + |
| 92 | +```javascript |
| 93 | +var nanmaxf = require( '@stdlib/math/base/special/nanmaxf' ); |
| 94 | + |
| 95 | +var m = nanmaxf( 3.0, 4.0 ); |
| 96 | +console.log( m ); |
| 97 | +// => 4.0 |
| 98 | + |
| 99 | +m = nanmaxf( NaN, 4.0 ); |
| 100 | +console.log( m ); |
| 101 | +// => 4.0 |
| 102 | + |
| 103 | +m = nanmaxf( 4.0, NaN ); |
| 104 | +console.log( m ); |
| 105 | +// => 4.0 |
| 106 | + |
| 107 | +m = nanmaxf( NaN, NaN ); |
| 108 | +console.log( m ); |
| 109 | +// => NaN |
| 110 | +``` |
| 111 | + |
| 112 | +</section> |
| 113 | + |
| 114 | +<!-- /.examples --> |
| 115 | + |
| 116 | +<!-- C interface documentation. --> |
| 117 | + |
| 118 | +* * * |
| 119 | + |
| 120 | +<section class="c"> |
| 121 | + |
| 122 | +## C APIs |
| 123 | + |
| 124 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 125 | + |
| 126 | +<section class="intro"> |
| 127 | + |
| 128 | +</section> |
| 129 | + |
| 130 | +<!-- /.intro --> |
| 131 | + |
| 132 | +<!-- C usage documentation. --> |
| 133 | + |
| 134 | +<section class="usage"> |
| 135 | + |
| 136 | +### Usage |
| 137 | + |
| 138 | +```c |
| 139 | +#include "stdlib/math/base/special/nanmaxf.h" |
| 140 | +``` |
| 141 | + |
| 142 | +#### stdlib_base_nanmaxf( x, y ) |
| 143 | + |
| 144 | +Returns the maximum value of two single-precision floating-point numbers, ignoring NaN. |
| 145 | + |
| 146 | +```c |
| 147 | +float out = stdlib_base_nanmaxf( 4.2f, 3.14f ); |
| 148 | +// returns 4.2f |
| 149 | + |
| 150 | +out = stdlib_base_nanmaxf( 4.14f, 0.0f / 0.0f ); |
| 151 | +// returns 4.14f |
| 152 | +``` |
| 153 | + |
| 154 | +The function accepts the following arguments: |
| 155 | + |
| 156 | +- **x**: `[in] float` input value. |
| 157 | +- **y**: `[in] float` input value. |
| 158 | + |
| 159 | +```c |
| 160 | +float stdlib_base_nanmaxf( const float x, const float y ); |
| 161 | +``` |
| 162 | +
|
| 163 | +</section> |
| 164 | +
|
| 165 | +<!-- /.usage --> |
| 166 | +
|
| 167 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 168 | +
|
| 169 | +<section class="notes"> |
| 170 | +
|
| 171 | +</section> |
| 172 | +
|
| 173 | +<!-- /.notes --> |
| 174 | +
|
| 175 | +<!-- C API usage examples. --> |
| 176 | +
|
| 177 | +<section class="examples"> |
| 178 | +
|
| 179 | +### Examples |
| 180 | +
|
| 181 | +```c |
| 182 | +#include "stdlib/math/base/special/nanmaxf.h" |
| 183 | +#include <stdio.h> |
| 184 | +
|
| 185 | +int main( void ) { |
| 186 | + const float x[] = { 1.0f, 0.45f, -0.89f, 0.0f / 0.0f, -0.78f, -0.22f, 0.66f, 0.11f, -0.55f, 0.0f }; |
| 187 | + const float y[] = { -0.22f, 0.66f, 0.0f, -0.55f, 0.33f, 1.0f, 0.0f / 0.0f, 0.11f, 0.45f, -0.78f }; |
| 188 | +
|
| 189 | + float v; |
| 190 | + int i; |
| 191 | + for ( i = 0; i < 10; i++ ) { |
| 192 | + v = stdlib_base_nanmaxf( x[ i ], y[ i ] ); |
| 193 | + printf( "x[ %d ]: %f, y[ %d ]: %f, nanmaxf( x[ %d ], y[ %d ] ): %f\n", i, x[ i ], i, y[ i ], i, i, v ); |
| 194 | + } |
| 195 | +} |
| 196 | +``` |
| 197 | + |
| 198 | +</section> |
| 199 | + |
| 200 | +<!-- /.examples --> |
| 201 | + |
| 202 | +</section> |
| 203 | + |
| 204 | +<!-- /.c --> |
| 205 | + |
| 206 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 207 | + |
| 208 | +<section class="related"> |
| 209 | + |
| 210 | +</section> |
| 211 | + |
| 212 | +<!-- /.related --> |
| 213 | + |
| 214 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 215 | + |
| 216 | +<section class="links"> |
| 217 | + |
| 218 | +<!-- <related-links> --> |
| 219 | + |
| 220 | +<!-- </related-links> --> |
| 221 | + |
| 222 | +</section> |
| 223 | + |
| 224 | +<!-- /.links --> |
0 commit comments