Skip to content

Commit

Permalink
Editorial: Express some Number methods more explicitly
Browse files Browse the repository at this point in the history
Specifically, write
- Number::bitwiseNOT
- Number::leftShift
- Number::signedRightShift
- Number::unsignedRightShift

in terms of NumberToInt32Bits/Int32BitsToNumber
or the analogous NumberToUint32Bits/Uint32BitsToNumber.
  • Loading branch information
jmdyck committed Jul 11, 2024
1 parent 927c7eb commit 56f7ee8
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1880,8 +1880,9 @@ <h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _oldValue_ be ! ToInt32(_x_).
1. Return the bitwise complement of _oldValue_. The mathematical value of the result is exactly representable as a 32-bit two's complement bit string.
1. Let _xbits_ be NumberToInt32Bits(_x_).
1. Let _cbits_ be the bitwise complement of _xbits_.
1. Return Int32BitsToNumber(_cbits_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -2084,10 +2085,11 @@ <h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _lnum_ be ! ToInt32(_x_).
1. Let _lbits_ be NumberToInt32Bits(_x_).
1. Let _rnum_ be ! ToUint32(_y_).
1. Let _shiftCount_ be ℝ(_rnum_) modulo 32.
1. Return the result of left shifting _lnum_ by _shiftCount_ bits. The mathematical value of the result is exactly representable as a 32-bit two's complement bit string.
1. Let _shifted_ be the result of left shifting _lbits_ by _shiftCount_ bits.
1. Return Int32BitsToNumber(_shifted_).
</emu-alg>
</emu-clause>

Expand All @@ -2101,10 +2103,11 @@ <h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _lnum_ be ! ToInt32(_x_).
1. Let _lbits_ be NumberToInt32Bits(_x_).
1. Let _rnum_ be ! ToUint32(_y_).
1. Let _shiftCount_ be ℝ(_rnum_) modulo 32.
1. Return the result of performing a sign-extending right shift of _lnum_ by _shiftCount_ bits. The most significant bit is propagated. The mathematical value of the result is exactly representable as a 32-bit two's complement bit string.
1. Let _shifted_ be the result of performing a sign-extending right shift of _lbits_ by _shiftCount_ bits. The most significant bit is propagated.
1. Return Int32BitsToNumber(_shifted_).
</emu-alg>
</emu-clause>

Expand All @@ -2118,10 +2121,11 @@ <h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _lnum_ be ! ToUint32(_x_).
1. Let _lbits_ be NumberToUint32Bits(_x_).
1. Let _rnum_ be ! ToUint32(_y_).
1. Let _shiftCount_ be ℝ(_rnum_) modulo 32.
1. Return the result of performing a zero-filling right shift of _lnum_ by _shiftCount_ bits. Vacated bits are filled with zero. The mathematical value of the result is exactly representable as a 32-bit unsigned bit string.
1. Let _shifted_ be the result of performing a zero-filling right shift of _lbits_ by _shiftCount_ bits. Vacated bits are filled with zero.
1. Return Uint32BitsToNumber(_shifted_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -2256,6 +2260,34 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-numbertouint32bits" type="abstract operation">
<h1>
NumberToUint32Bits (
_number_: a Number,
): a 32-bit bit string
</h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _n_ be ! ToUint32(_number_).
1. Return the 32-bit unsigned bit string representing ℝ(_n_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-uint32bitstonumber" type="abstract operation">
<h1>
Uint32BitsToNumber (
_bits_: a 32-bit bit string,
): an integral Number
</h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _i_ be the result of interpreting _bits_ as a 32-bit unsigned integer.
1. Return 𝔽(_i_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-numeric-types-number-bitwiseAND" type="numeric method">
<h1>
Number::bitwiseAND (
Expand Down

0 comments on commit 56f7ee8

Please sign in to comment.