|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# FLOAT32_MAX_SAFE_LUCAS |
| 22 | + |
| 23 | +> Maximum safe [Lucas number][lucas-number] when stored in [single-precision floating-point][ieee754] format. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var FLOAT32_MAX_SAFE_LUCAS = require( '@stdlib/constants/float32/max-safe-lucas' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### FLOAT32_MAX_SAFE_LUCAS |
| 34 | + |
| 35 | +The maximum [safe][safe-integers] [Lucas number][lucas-number] when stored in [single-precision floating-point][ieee754] format. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var bool = ( FLOAT32_MAX_SAFE_LUCAS === 12752043 ); |
| 39 | +// returns true |
| 40 | +``` |
| 41 | + |
| 42 | +</section> |
| 43 | + |
| 44 | +<!-- /.usage --> |
| 45 | + |
| 46 | +<section class="examples"> |
| 47 | + |
| 48 | +## Examples |
| 49 | + |
| 50 | +<!-- eslint no-undef: "error" --> |
| 51 | + |
| 52 | +```javascript |
| 53 | +var FLOAT32_MAX_SAFE_LUCAS = require( '@stdlib/constants/float32/max-safe-lucas' ); |
| 54 | + |
| 55 | +function lucas( n ) { |
| 56 | + var a; |
| 57 | + var b; |
| 58 | + var c; |
| 59 | + var i; |
| 60 | + |
| 61 | + a = 2; |
| 62 | + if ( n === 0 ) { |
| 63 | + return a; |
| 64 | + } |
| 65 | + b = 1; |
| 66 | + for ( i = 2; i <= n; i++ ) { |
| 67 | + c = a + b; |
| 68 | + a = b; |
| 69 | + b = c; |
| 70 | + } |
| 71 | + return b; |
| 72 | +} |
| 73 | + |
| 74 | +var v; |
| 75 | +var i; |
| 76 | +for ( i = 0; i < 100; i++ ) { |
| 77 | + v = lucas( i ); |
| 78 | + if ( v > FLOAT32_MAX_SAFE_LUCAS ) { |
| 79 | + console.log( 'Unsafe: %d', v ); |
| 80 | + } else { |
| 81 | + console.log( 'Safe: %d', v ); |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +</section> |
| 87 | + |
| 88 | +<!-- /.examples --> |
| 89 | + |
| 90 | +<!-- C interface documentation. --> |
| 91 | + |
| 92 | +* * * |
| 93 | + |
| 94 | +<section class="c"> |
| 95 | + |
| 96 | +## C APIs |
| 97 | + |
| 98 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 99 | + |
| 100 | +<section class="intro"> |
| 101 | + |
| 102 | +</section> |
| 103 | + |
| 104 | +<!-- /.intro --> |
| 105 | + |
| 106 | +<!-- C usage documentation. --> |
| 107 | + |
| 108 | +<section class="usage"> |
| 109 | + |
| 110 | +### Usage |
| 111 | + |
| 112 | +```c |
| 113 | +#include "stdlib/constants/float32/max_safe_lucas.h" |
| 114 | +``` |
| 115 | + |
| 116 | +#### STDLIB_CONSTANT_FLOAT32_MAX_SAFE_LUCAS |
| 117 | + |
| 118 | +Macro for the maximum [safe][safe-integers] [Lucas number][lucas-number] when stored in [single-precision floating-point][ieee754] format. |
| 119 | + |
| 120 | +</section> |
| 121 | + |
| 122 | +<!-- /.usage --> |
| 123 | + |
| 124 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 125 | + |
| 126 | +<section class="notes"> |
| 127 | + |
| 128 | +</section> |
| 129 | + |
| 130 | +<!-- /.notes --> |
| 131 | + |
| 132 | +<!-- C API usage examples. --> |
| 133 | + |
| 134 | +<section class="examples"> |
| 135 | + |
| 136 | +</section> |
| 137 | + |
| 138 | +<!-- /.examples --> |
| 139 | + |
| 140 | +</section> |
| 141 | + |
| 142 | +<!-- /.c --> |
| 143 | + |
| 144 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 145 | + |
| 146 | +<section class="related"> |
| 147 | + |
| 148 | +</section> |
| 149 | + |
| 150 | +<!-- /.related --> |
| 151 | + |
| 152 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 153 | + |
| 154 | +<section class="links"> |
| 155 | + |
| 156 | +[safe-integers]: http://www.2ality.com/2013/10/safe-integers.html |
| 157 | + |
| 158 | +[lucas-number]: https://en.wikipedia.org/wiki/Lucas_number |
| 159 | + |
| 160 | +[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985 |
| 161 | + |
| 162 | +<!-- <related-links> --> |
| 163 | + |
| 164 | +<!-- </related-links> --> |
| 165 | + |
| 166 | +</section> |
| 167 | + |
| 168 | +<!-- /.links --> |
0 commit comments