@stdlib/math-base-special-copysignf 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,277 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2021 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
+ # copysignf
22
+
23
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
24
+
25
+ > Return a [single-precision floating-point number][ieee754] with the magnitude of `x` and the sign of `y`.
26
+
27
+ <section class="installation">
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ npm install @stdlib/math-base-special-copysignf
33
+ ```
34
+
35
+ </section>
36
+
37
+ <section class="usage">
38
+
39
+ ## Usage
40
+
41
+ ```javascript
42
+ var copysignf = require( '@stdlib/math-base-special-copysignf' );
43
+ ```
44
+
45
+ #### copysignf( x, y )
46
+
47
+ Returns a [single-precision floating-point number][ieee754] with the magnitude of `x` and the sign of `y`.
48
+
49
+ ```javascript
50
+ var z = copysignf( -3.0, 10.0 );
51
+ // returns 3.0
52
+
53
+ z = copysignf( 3.0, -1.0 );
54
+ // returns -3.0
55
+
56
+ z = copysignf( 1.0, -0.0 );
57
+ // returns -1.0
58
+
59
+ z = copysignf( -3.0, -0.0 );
60
+ // returns -3.0
61
+
62
+ z = copysignf( -0.0, 1.0 );
63
+ // returns 0.0
64
+ ```
65
+
66
+ </section>
67
+
68
+ <!-- /.usage -->
69
+
70
+ <section class="notes">
71
+
72
+ ## Notes
73
+
74
+ - According to the [IEEE754][ieee754] standard, a `NaN` has a biased exponent equal to `255`, a significand greater than `0`, and a sign bit equal to **either** `1` **or** `0`. In which case, `NaN` may not correspond to just one but many binary representations. Accordingly, care should be taken to ensure that `y` is **not** `NaN`; otherwise, behavior may be indeterminate.
75
+
76
+ </section>
77
+
78
+ <!-- /.notes -->
79
+
80
+ <section class="examples">
81
+
82
+ ## Examples
83
+
84
+ <!-- eslint no-undef: "error" -->
85
+
86
+ ```javascript
87
+ var randu = require( '@stdlib/random-base-randu' );
88
+ var copysignf = require( '@stdlib/math-base-special-copysignf' );
89
+
90
+ var x;
91
+ var y;
92
+ var z;
93
+ var i;
94
+
95
+ // Generate random numbers `x` and `y` and copy the sign of `y` to `x`...
96
+ for ( i = 0; i < 100; i++ ) {
97
+ x = (randu()*100.0) - 50.0;
98
+ y = (randu()*10.0) - 5.0;
99
+ z = copysignf( x, y );
100
+ console.log( 'x: %d, y: %d => %d', x, y, z );
101
+ }
102
+ ```
103
+
104
+ </section>
105
+
106
+ <!-- /.examples -->
107
+
108
+ <!-- C interface documentation. -->
109
+
110
+ * * *
111
+
112
+ <section class="c">
113
+
114
+ ## C APIs
115
+
116
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
117
+
118
+ <section class="intro">
119
+
120
+ </section>
121
+
122
+ <!-- /.intro -->
123
+
124
+ <!-- C usage documentation. -->
125
+
126
+ <section class="usage">
127
+
128
+ ### Usage
129
+
130
+ ```c
131
+ #include "stdlib/math/base/special/copysignf.h"
132
+ ```
133
+
134
+ #### stdlib_base_copysignf( x, y )
135
+
136
+ Returns a [single-precision floating-point number][ieee754] with the magnitude of `x` and the sign of `y`.
137
+
138
+ ```c
139
+ float v = stdlib_base_copysignf( -3.0f, 10.0f );
140
+ // returns 3.0f
141
+
142
+ float v = stdlib_base_copysignf( 3.0f, -1.0f );
143
+ // returns -3.0f
144
+ ```
145
+
146
+ The function accepts the following arguments:
147
+
148
+ - **x**: `[in] float` number from which to derive a magnitude.
149
+ - **y**: `[in] float` number from which to derive a sign.
150
+
151
+ ```c
152
+ float stdlib_base_copysignf( const float x, const float y );
153
+ ```
154
+
155
+ </section>
156
+
157
+ <!-- /.usage -->
158
+
159
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
160
+
161
+ <section class="notes">
162
+
163
+ </section>
164
+
165
+ <!-- /.notes -->
166
+
167
+ <!-- C API usage examples. -->
168
+
169
+ <section class="examples">
170
+
171
+ ### Examples
172
+
173
+ ```c
174
+ #include "stdlib/math/base/special/copysignf.h"
175
+ #include <stdio.h>
176
+
177
+ int main() {
178
+ float x[] = { 3.0f, -3.0f, 0.0f, 0.0f/0.0f };
179
+
180
+ float y;
181
+ int i;
182
+ for ( i = 0; i < 4; i++ ) {
183
+ y = stdlib_base_copysignf( x[ i ], -3.0f );
184
+ printf( "copysignf(%f, %f) = %f\n", x[ i ], -3.0f, y );
185
+ }
186
+ }
187
+ ```
188
+
189
+ </section>
190
+
191
+ <!-- /.examples -->
192
+
193
+ </section>
194
+
195
+ <!-- /.c -->
196
+
197
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
198
+
199
+ <section class="related">
200
+
201
+ </section>
202
+
203
+ <!-- /.related -->
204
+
205
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
206
+
207
+
208
+ <section class="main-repo" >
209
+
210
+ * * *
211
+
212
+ ## Notice
213
+
214
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
215
+
216
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
217
+
218
+ #### Community
219
+
220
+ [![Chat][chat-image]][chat-url]
221
+
222
+ ---
223
+
224
+ ## License
225
+
226
+ See [LICENSE][stdlib-license].
227
+
228
+
229
+ ## Copyright
230
+
231
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
232
+
233
+ </section>
234
+
235
+ <!-- /.stdlib -->
236
+
237
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
238
+
239
+ <section class="links">
240
+
241
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-special-copysignf.svg
242
+ [npm-url]: https://npmjs.org/package/@stdlib/math-base-special-copysignf
243
+
244
+ [test-image]: https://github.com/stdlib-js/math-base-special-copysignf/actions/workflows/test.yml/badge.svg
245
+ [test-url]: https://github.com/stdlib-js/math-base-special-copysignf/actions/workflows/test.yml
246
+
247
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-special-copysignf/main.svg
248
+ [coverage-url]: https://codecov.io/github/stdlib-js/math-base-special-copysignf?branch=main
249
+
250
+ <!--
251
+
252
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/math-base-special-copysignf.svg
253
+ [dependencies-url]: https://david-dm.org/stdlib-js/math-base-special-copysignf/main
254
+
255
+ -->
256
+
257
+ [umd]: https://github.com/umdjs/umd
258
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
259
+
260
+ [deno-url]: https://github.com/stdlib-js/math-base-special-copysignf/tree/deno
261
+ [umd-url]: https://github.com/stdlib-js/math-base-special-copysignf/tree/umd
262
+ [esm-url]: https://github.com/stdlib-js/math-base-special-copysignf/tree/esm
263
+
264
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
265
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
266
+
267
+ [stdlib]: https://github.com/stdlib-js/stdlib
268
+
269
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
270
+
271
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-base-special-copysignf/main/LICENSE
272
+
273
+ [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
274
+
275
+ </section>
276
+
277
+ <!-- /.links -->
package/docs/repl.txt ADDED
@@ -0,0 +1,34 @@
1
+
2
+ {{alias}}( x, y )
3
+ Returns a single-precision floating-point number with the magnitude of `x`
4
+ and the sign of `y`.
5
+
6
+ Parameters
7
+ ----------
8
+ x: number
9
+ Number from which to derive a magnitude.
10
+
11
+ y: number
12
+ Number from which to derive a sign.
13
+
14
+ Returns
15
+ -------
16
+ z: number
17
+ Single-precision floating-point number.
18
+
19
+ Examples
20
+ --------
21
+ > var z = {{alias}}( -3.0, 10.0 )
22
+ 3.0
23
+ > z = {{alias}}( 3.0, -1.0 )
24
+ -3.0
25
+ > z = {{alias}}( 1.0, -0.0 )
26
+ -1.0
27
+ > z = {{alias}}( -3.0, -0.0 )
28
+ -3.0
29
+ > z = {{alias}}( -0.0, 1.0 )
30
+ 0.0
31
+
32
+ See Also
33
+ --------
34
+
@@ -0,0 +1,53 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2021 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
+ // TypeScript Version: 2.0
20
+
21
+ /**
22
+ * Returns a single-precision floating-point number with the magnitude of `x` and the sign of `y`.
23
+ *
24
+ * @param x - number from which to derive a magnitude
25
+ * @param y - number from which to derive a sign
26
+ * @returns a single-precision floating-point number
27
+ *
28
+ * @example
29
+ * var z = copysignf( -3.0, 10.0 );
30
+ * // returns 3.0
31
+ *
32
+ * @example
33
+ * var z = copysignf( 3.0, -1.0 );
34
+ * // returns -3.0
35
+ *
36
+ * @example
37
+ * var z = copysignf( 1.0, -0.0 );
38
+ * // returns -1.0
39
+ *
40
+ * @example
41
+ * var z = copysignf( -3.0, -0.0 );
42
+ * // returns -3.0
43
+ *
44
+ * @example
45
+ * var z = copysignf( -0.0, 1.0 );
46
+ * // returns 0.0
47
+ */
48
+ declare function copysignf( x: number, y: number ): number;
49
+
50
+
51
+ // EXPORTS //
52
+
53
+ export = copysignf;
@@ -0,0 +1,57 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2021 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
+ import copysignf = require( './index' );
20
+
21
+
22
+ // TESTS //
23
+
24
+ // The function returns a number...
25
+ {
26
+ copysignf( -3.14, 10 ); // $ExpectType number
27
+ copysignf( 3.14, -10 ); // $ExpectType number
28
+ }
29
+
30
+ // The function does not compile if provided values other than two numbers...
31
+ {
32
+ copysignf( true, 3 ); // $ExpectError
33
+ copysignf( false, 2 ); // $ExpectError
34
+ copysignf( '5', 1 ); // $ExpectError
35
+ copysignf( [], 1 ); // $ExpectError
36
+ copysignf( {}, 2 ); // $ExpectError
37
+ copysignf( ( x: number ): number => x, 2 ); // $ExpectError
38
+
39
+ copysignf( -9, true ); // $ExpectError
40
+ copysignf( -9, false ); // $ExpectError
41
+ copysignf( -5, '5' ); // $ExpectError
42
+ copysignf( -8, [] ); // $ExpectError
43
+ copysignf( -9, {} ); // $ExpectError
44
+ copysignf( -8, ( x: number ): number => x ); // $ExpectError
45
+
46
+ copysignf( [], true ); // $ExpectError
47
+ copysignf( {}, false ); // $ExpectError
48
+ copysignf( false, '5' ); // $ExpectError
49
+ copysignf( {}, [] ); // $ExpectError
50
+ copysignf( '5', ( x: number ): number => x ); // $ExpectError
51
+ }
52
+
53
+ // The function does not compile if provided insufficient arguments...
54
+ {
55
+ copysignf(); // $ExpectError
56
+ copysignf( -3 ); // $ExpectError
57
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2021 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
+ #ifndef STDLIB_MATH_BASE_SPECIAL_COPYSIGNF_H
20
+ #define STDLIB_MATH_BASE_SPECIAL_COPYSIGNF_H
21
+
22
+ /*
23
+ * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
24
+ */
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ /**
30
+ * Returns a single-precision floating-point number with the magnitude of `x` and the sign of `y`.
31
+ */
32
+ float stdlib_base_copysignf( const float x, const float y );
33
+
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+
38
+ #endif // !STDLIB_MATH_BASE_SPECIAL_COPYSIGNF_H
package/include.gypi ADDED
@@ -0,0 +1,53 @@
1
+ # @license Apache-2.0
2
+ #
3
+ # Copyright (c) 2021 The Stdlib Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # A GYP include file for building a Node.js native add-on.
18
+ #
19
+ # Main documentation:
20
+ #
21
+ # [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
22
+ # [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
23
+ {
24
+ # Define variables to be used throughout the configuration for all targets:
25
+ 'variables': {
26
+ # Source directory:
27
+ 'src_dir': './src',
28
+
29
+ # Include directories:
30
+ 'include_dirs': [
31
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
32
+ ],
33
+
34
+ # Add-on destination directory:
35
+ 'addon_output_dir': './src',
36
+
37
+ # Source files:
38
+ 'src_files': [
39
+ '<(src_dir)/addon.c',
40
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
41
+ ],
42
+
43
+ # Library dependencies:
44
+ 'libraries': [
45
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
46
+ ],
47
+
48
+ # Library directories:
49
+ 'library_dirs': [
50
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
51
+ ],
52
+ }, # end variables
53
+ }
package/lib/index.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2021 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
+ * Return a single-precision floating-point number with the magnitude of `x` and the sign of `y`.
23
+ *
24
+ * @module @stdlib/math-base-special-copysignf
25
+ *
26
+ * @example
27
+ * var copysignf = require( '@stdlib/math-base-special-copysignf' );
28
+ *
29
+ * var z = copysignf( -3.0, 10.0 );
30
+ * // returns 3.0
31
+ *
32
+ * z = copysignf( 3.0, -1.0 );
33
+ * // returns -3.0
34
+ *
35
+ * z = copysignf( 1.0, -0.0 );
36
+ * // returns -1.0
37
+ *
38
+ * z = copysignf( -3.0, -0.0 );
39
+ * // returns -3.0
40
+ *
41
+ * z = copysignf( -0.0, 1.0 );
42
+ * // returns 0.0
43
+ */
44
+
45
+ // MODULES //
46
+
47
+ var main = require( './main.js' );
48
+
49
+
50
+ // EXPORTS //
51
+
52
+ module.exports = main;
package/lib/main.js ADDED
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2021 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 float64ToFloat32 = require( '@stdlib/number-float64-base-to-float32' );
24
+ var toWord = require( '@stdlib/number-float32-base-to-word' );
25
+ var fromWord = require( '@stdlib/number-float32-base-from-word' );
26
+
27
+
28
+ // VARIABLES //
29
+
30
+ // 10000000000000000000000000000000 => 2147483648 => 0x80000000
31
+ var SIGN_MASK = 0x80000000>>>0; // asm type annotation
32
+
33
+ // 01111111111111111111111111111111 => 2147483647 => 0x7fffffff
34
+ var MAGNITUDE_MASK = 0x7fffffff|0; // asm type annotation
35
+
36
+
37
+ // MAIN //
38
+
39
+ /**
40
+ * Returns a single-precision floating-point number with the magnitude of `x` and the sign of `y`.
41
+ *
42
+ * @param {number} x - number from which to derive a magnitude
43
+ * @param {number} y - number from which to derive a sign
44
+ * @returns {number} a single-precision floating-point number
45
+ *
46
+ * @example
47
+ * var z = copysignf( -3.0, 10.0 );
48
+ * // returns 3.0
49
+ *
50
+ * @example
51
+ * var z = copysignf( 3.0, -1.0 );
52
+ * // returns -3.0
53
+ *
54
+ * @example
55
+ * var z = copysignf( 1.0, -0.0 );
56
+ * // returns -1.0
57
+ *
58
+ * @example
59
+ * var z = copysignf( -3.0, -0.0 );
60
+ * // returns -3.0
61
+ *
62
+ * @example
63
+ * var z = copysignf( -0.0, 1.0 );
64
+ * // returns 0.0
65
+ */
66
+ function copysignf( x, y ) {
67
+ var wx;
68
+ var wy;
69
+
70
+ x = float64ToFloat32( x );
71
+ y = float64ToFloat32( y );
72
+
73
+ // Convert `x` to an unsigned integer:
74
+ wx = toWord( x );
75
+
76
+ // Turn off the sign bit of `x`:
77
+ wx &= MAGNITUDE_MASK;
78
+
79
+ // Convert `y` to an unsigned integer:
80
+ wy = toWord( y );
81
+
82
+ // Leave only the sign bit of `y` turned on:
83
+ wy &= SIGN_MASK;
84
+
85
+ // Copy the sign bit of `y` to `x`:
86
+ wx |= wy;
87
+
88
+ // Return a new value having the same magnitude as `x`, but with the sign of `y`:
89
+ return fromWord( wx );
90
+ }
91
+
92
+
93
+ // EXPORTS //
94
+
95
+ module.exports = copysignf;