File tree Expand file tree Collapse file tree 3 files changed +165
-0
lines changed
lib/node_modules/@stdlib/math/base/special/lcmf/lib Expand file tree Collapse file tree 3 files changed +165
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @license Apache-2.0
3+ *
4+ * Copyright (c) 2018 The Stdlib Authors.
5+ *
6+ * Licensed under the Apache License, Version 2.0 (the "License");
7+ * you may not use this file except in compliance with the License.
8+ * You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing, software
13+ * distributed under the License is distributed on an "AS IS" BASIS,
14+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ * See the License for the specific language governing permissions and
16+ * limitations under the License.
17+ */
18+
19+ 'use strict' ;
20+
21+ /**
22+ * Compute the least common multiple (lcm) of two single-precision floating-point numbers.
23+ *
24+ * @module @stdlib /math/base/special/lcmf
25+ *
26+ * @example
27+ * var lcmf = require( '@stdlib/math/base/special/lcmf' );
28+ *
29+ * var v = lcmf( 21, 6 );
30+ * // returns 42
31+ */
32+
33+ // MODULES //
34+
35+ var main = require ( './main.js' ) ;
36+
37+
38+ // EXPORTS //
39+
40+ module . exports = main ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @license Apache-2.0
3+ *
4+ * Copyright (c) 2018 The Stdlib Authors.
5+ *
6+ * Licensed under the Apache License, Version 2.0 (the "License");
7+ * you may not use this file except in compliance with the License.
8+ * You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing, software
13+ * distributed under the License is distributed on an "AS IS" BASIS,
14+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ * See the License for the specific language governing permissions and
16+ * limitations under the License.
17+ */
18+
19+ 'use strict' ;
20+
21+ // MODULES //
22+
23+ var isnanf = require ( '@stdlib/math/base/assert/is-nanf' ) ;
24+ var gcdf = require ( '@stdlib/math/base/special/gcdf' ) ;
25+
26+
27+ // MAIN //
28+
29+ /**
30+ * Computes the least common multiple (lcm) of two single-precision floating-point numbers.
31+ *
32+ * @param {integer } a - integer
33+ * @param {integer } b - integer
34+ * @returns {integer } least common multiple
35+ *
36+ * @example
37+ * var v = lcmf( 21, 6 );
38+ * // returns 42
39+ *
40+ * @example
41+ * var v = lcmf( 3.14, 6 );
42+ * // returns NaN
43+ *
44+ * @example
45+ * var v = lcmf( NaN, 6 );
46+ * // returns NaN
47+ */
48+ function lcmf ( a , b ) {
49+ var d ;
50+ if ( a === 0 || b === 0 ) {
51+ return 0 ;
52+ }
53+ if ( a < 0 ) {
54+ a = - a ;
55+ }
56+ if ( b < 0 ) {
57+ b = - b ;
58+ }
59+ // Note: we rely on `gcdf` to perform further argument validation...
60+ d = gcdf ( a , b ) ;
61+ if ( isnanf ( d ) ) {
62+ return d ;
63+ }
64+ return ( a / d ) * b ;
65+ }
66+
67+
68+ // EXPORTS //
69+
70+ module . exports = lcmf ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @license Apache-2.0
3+ *
4+ * Copyright (c) 2024 The Stdlib Authors.
5+ *
6+ * Licensed under the Apache License, Version 2.0 (the "License");
7+ * you may not use this file except in compliance with the License.
8+ * You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing, software
13+ * distributed under the License is distributed on an "AS IS" BASIS,
14+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ * See the License for the specific language governing permissions and
16+ * limitations under the License.
17+ */
18+
19+ 'use strict' ;
20+
21+ // MODULES //
22+
23+ var addon = require ( './../src/addon.node' ) ;
24+
25+
26+ // MAIN //
27+
28+ /**
29+ * Computes the least common multiple (lcm) of two single-precision floating-point numbers.
30+ *
31+ * @private
32+ * @param {integer } a - integer
33+ * @param {integer } b - integer
34+ * @returns {number } least common multiple
35+ *
36+ * @example
37+ * var v = lcmf( 21.0, 6.0 );
38+ * // returns 42.0
39+ *
40+ * @example
41+ * var v = lcmf( 3.14, 6.0 );
42+ * // returns NaN
43+ *
44+ * @example
45+ * var v = lcmf( NaN, 6.0 );
46+ * // returns NaN
47+ */
48+ function lcmf ( a , b ) {
49+ return addon ( a , b ) ;
50+ }
51+
52+
53+ // EXPORTS //
54+
55+ module . exports = lcmf ;
You can’t perform that action at this time.
0 commit comments