A method for converting a bitstream implemented by a computer into a floating-point number
By dynamically determining the exponent part and mantissa part of floating-point numbers through bit-unit shifts and independent bit selection, the method enhances the generation of floating-point numbers from bit streams, improving efficiency and reducing energy consumption.
Patent Information
- Application Number
- JP2025502562
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-07-18
- Filing Date
- 2023-07-18
- Publication Date
- 2025-07-30
- Estimated Expiration
- 2043-07-18
AI Technical Summary
Existing methods for converting bit streams into floating-point numbers are limited in generating a large number of floating-point numbers with specific precision.
A method that dynamically determines the exponent part of a floating-point number by counting bit-unit shifts to obtain a bit value of 1 at a specified position in the bitstream, and independently determines the mantissa part using a different set of bits, allowing for efficient conversion of bit streams into floating-point numbers.
This method reduces the number of bits required for the exponent part, enabling more floating-point numbers to be generated from a given bit stream without reducing accuracy, thus reducing energy consumption and increasing the number of floating-point numbers obtainable.
Smart Images

Figure 2025524683000001_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method implemented by a computer for converting a bitstream into a floating-point number according to independent claim 1, and a computing system suitable for converting a bitstream into a floating-point number according to independent claim 15.
Background Art
[0002] To represent decimal numbers, a computer typically uses either a fixed-point format or a floating-point format. For example, a floating-point number f can be represented as follows.
Number
[0003] The most common standard for representing floating-point numbers used in computers is the IEEE-754 standard. According to this standard, a floating-point number includes a single sign bit, a specific number of bits representing the exponent part and a specific number of bits representing the mantissa part, which depends on the precision of the floating-point number. A single-precision floating-point number, for example, when having a precision of 32 bits, has a sign bit of a single bit, an exponent part of 8 bits, and a mantissa part of 23 bits.
[0004] In certain cases, a computer needs to convert a stream of binary digits into a sequence of floating-point numbers with a specific precision. This could be the case, for example, when a computer obtains a stream of binary digits that is more uniformly distributed than a physical random bit generator, and has the task of converting said bit stream into a sequence of uniformly distributed floating-point numbers. For example, using the representation in the IEEE-754 standard, the computer shifts a window of the same size as the generated floating-point numbers over the bit stream for each size of the floating-point number, and performs this task by converting a fixed number of bits within the window into a floating-point number. Thus, the number of floating-point numbers that can be generated from the bit stream is defined by the precision of the generated floating-point numbers, in particular by the format used for the floating-point numbers, in order to define the size of the sliding window. Summary of the Invention Problems to be Solved by the Invention
[0005] Compared with the prior art, the technical problem raised by the present invention is to provide a method for converting a bit stream into one or more floating-point numbers, according to which, on average, a larger number of floating-point numbers with a specific precision can be obtained from the bit stream. Means for Solving the Problems
[0006] This problem is solved by a method implemented by a computer according to independent claim 1, and by a computer system according to independent claim 15. More preferred embodiments are provided by each dependent claim.
[0007] The method implemented by a computer according to the present invention includes obtaining a bitstream and performing a conversion of the bitstream into a floating-point number, the floating-point number including an exponent part and a significand part, the conversion including determining the exponent part of the floating-point number based on counting the number of bit-unit shifts required to obtain a bit value 1 at a specified position of the bitstream, the conversion further including determining the significand part of the floating-point number based on a specific number of the bits different from the bits used when determining the exponent part.
[0008] The significand part may also be called the mantissa. Generally, the two expressions are used interchangeably.
[0009] Regarding a bitstream obtained by a method implemented by a computer, a binary stream means that each digit has a value of 0 or 1. Preferably, the bitstream includes a stream of random binary digits (uniformly distributed). Such (uniformly distributed) random binary digits are obtained by an independently and similarly distributed random bit generator, such as a physical random bit generator including, for example, a vertical cavity surface emitting laser or including a quantum phase diffusion method. Also, random binary digits can be generated using two lasers, where one laser operates in a constant mode and the other laser operates in a pulse mode. When the laser in the pulse mode is driven below or above its oscillation threshold, the relative phase relationship between its laser pulse and the laser driven constantly becomes random, facilitating the generation of (uniformly distributed) random binary digits. However, this method is not limited to a stream of (uniformly distributed) random binary digits. This method can also be applied, for example, when converting a stream including a stream of non-random binary digits, a pseudo-random binary stream, or any combination of random, pseudo-random, and / or non-random binary digits into one or more floating-point numbers.
[0010] The specified position may be any position of one bit in the bitstream. This may be the first bit of the bitstream (from either the left or the right), or any other bit in between. In particular, if more than one floating-point number is obtained from the bitstream, the specified bit for the first determined floating-point number is the first bit of the bitstream (from either the left or the right), and the specified position for the subsequently determined floating-point numbers may be the bit immediately to the right or left of the nearest bit used to obtain the previous floating-point number.
[0011] Bitwise shifting can include left shifting or right shifting and preferably includes a single 1-bit shift per bitwise shift, although shifts of more than 1 bit per shift are also encompassed by the present disclosure. In one embodiment, the bitwise shifts performed by the method to obtain the bit value of 1 at a specified position in the bit stream are of the same type. This means, for example, that the first bitwise shift performed by the method is a right shift and all subsequent bitwise shifts performed to obtain the bit value of 1 at the specified position in the bit stream are also right shifts.
[0012] As an option, the method can include reshuffling the bit stream, which can be done after obtaining the bit stream and before determining the exponent part. Such reshuffling of the bit stream can include random reshuffling, pseudo-random reshuffling, and non-random reshuffling such as hash operations. By reshuffling the bit stream by the method described above, additional security considerations can be added to the method, different from the original bit stream obtained by this method. This is relevant, for example, when the bit stream is a stream of random bits that are uniformly distributed and is intended, for example, for the generation of a random secret password.
[0013] Instead of using a fixed value for the number of bits of a bit stream to determine the exponent part of a floating-point number, the method according to the present invention dynamically determines the number of bits of the bit stream required to identify the exponent part of the floating-point number by performing a bit-by-bit shift of the bit stream at a specified position of the bit stream until a bit having a value of 1 is obtained. For at least a uniformly distributed random bit stream, since the probability that one bit has a value of 1 is 50%, the number of shifts starting from the specified position is usually 0 (if the bit at the specified position is already 1), and in most cases (87.5%), it is 1 or 2. By using this bit, for example, as the most significant bit for determining the exponent part of a 32-bit floating-point number, in most cases, the number of bits required for the exponent part is reduced by at least 5 on average. Incidentally, compared with the prior art, for example, the quantity of bits used to obtain a 32-bit floating-point number is significantly reduced, and thus, more floating-point numbers can be obtained from a bit stream of a given length without reducing the accuracy of the floating-point numbers.
[0014] Advantageously, since the generation of a specific number of floating-point numbers requires, on average, obtaining fewer bits from the bit source, the method can also reduce energy consumption, for example, it may be a physical random bit generator. The fewer bits that need to be generated, the less energy is consumed by the physical random bit generator, and thus, the less energy is required to generate the floating-point numbers.
[0015] As the designated position of the bitstream, any bit position in the bitstream can be specified. The designated position of the bitstream may be, for example, the most significant bit (or the leftmost bit) or the least significant bit (or the rightmost bit) of the bitstream. However, any other bit position located between the most significant bit and the least significant bit of the bitstream can also be selected as the designated position of the bitstream.
[0016] In one embodiment, the specific number of bits includes bits in front of the bit at the designated position in the bitstream that start from the designated position of the bitstream and have a value of 1, or the specific number of bits includes bits behind the first bit that start from the designated position of the bitstream and have a value of 1. This ensures that the specific number of bits used to determine the mantissa part and the bits used to determine the exponent part are different from each other. Next, there is no correlation between the exponent part and the mantissa part of the floating-point number, which is relevant, for example, when a uniformly distributed random binary number stream is converted into a uniformly distributed floating-point number stream. The specific number of bits located in front of the designated position may be a sequence of consecutive bits, however, a sequence of non-consecutive bits is also conceivable. The same applies to the specific number of bits following the first bit that start from the designated position of the bitstream and have a value of 1.
[0017] In a further embodiment, the bitwise shift is a left shift, and the specific number of bits is, starting from the specified position of the bit stream, the bit immediately preceding the bit at the specified position of the bit stream that has a value of 1, or the specific number of bits can include the bit immediately following the first bit that has a value of 1, starting from the specified position of the bit stream. This can be considered, for example, when the specified position of the bit stream is designated as the most significant position of the bit stream. Also, when the bitwise shift is a right shift, the specific number of bits is, starting from the specified position of the bit stream, the bit immediately following the bit at the specified position of the bit stream that has a value of 1, or the specific number of bits can include the bit immediately preceding the first bit that has a value of 1, starting from the specified position of the bit stream. This can be considered, for example, when the specified position of the bit stream is selected as the least significant position of the bit stream.
[0018] In another embodiment, the specific number of bits includes a first specific number of bits in front of the bit at the specified position of the bit stream that has a value of 1, starting from the specified position of the bit stream, and a second specific number of bits behind the first bit. Thereby, for example, even when the bits in front of the bit at the specified position in the bit stream that is close to the most significant position of the bit stream and has a value of 1, or the bits behind the first bit that are behind the bit at the specified position in the bit stream are insufficient to specify the mantissa part of the floating-point number, it enables efficient use of the bits in the bit stream. This is advantageous when the specified position is randomly selected.
[0019] In a further embodiment, when the number of bit - unit shifts is equal to a threshold value, the value of the exponent part is a fixed value to be imparted. Thereby, even if the number of bit - unit shifts required to obtain a bit having a value of 1 at the specified position of the bit stream is, for example, too large to be represented by the number of bits of the floating - point number reserved for the exponent part, or even if the floating - point number has only bits having a value of 0, it is guaranteed that the exponent part can be generated by the method. The threshold value may be equal to, for example, the number of bits used for the exponent part of a given floating - point number format. For example, the threshold value may be 8. The given value can be arbitrarily selected and, by default, may be 1 or 0. Or, if the threshold value is reached, the given fixed value may be a randomly determined value determined independently of the bit stream itself and is thus also regarded as a given fixed value within the present disclosure. Or, when the threshold value is reached, the value of the exponent part is fixed, by default, to the lowest value possible for it, thus facilitating the generation of non - normalized floating - point numbers.
[0020] In a further embodiment, the floating - point number has a sign. By including a sign, the range of floating - point numbers that can be generated from the bit stream is doubled, and for a particular embodiment of the method, it is advantageous when, for example, in a subsequent process, any number within the range of [−1; 1] or any other range including positive and negative numerical values is required.
[0021] In a further embodiment, the conversion includes determining the sign of the floating-point number based on the value of a sign bit that has a value of 1 and is located either in front of the bit at the specified position or behind the first bit in the bitstream, starting from the specified position in the bitstream. This ensures that the bits used to determine the sign of the floating-point number are different from the bits used to determine the exponent part of the floating-point number. However, it is unknown whether the bits used to determine the sign of the floating-point number have already been used to determine the mantissa part. For such a specific embodiment, it is preferable that the sign bit is also different from the bits used to determine the mantissa part. This may be the case, for example, when a bitstream of uniformly distributed binary digits is converted into a sequence of uniformly distributed floating-point numbers, because in such a special case, there is no correlation between the sign of the floating-point number and the mantissa part.
[0022] In a further embodiment, when the value of the sign bit is 0, the sign of the floating-point number is positive, and when the value of the sign bit is 1, the sign of the floating-point number is negative, or when the value of the sign bit is 1, the sign of the floating-point number is positive, and when the value of the sign bit is 0, the sign of the floating-point number is negative. Compared with the IEEE-754 standard, this method provides a second representation format for the sign bit.
[0023] In a further embodiment, determining the exponent part further includes determining the difference between the number of bitwise shifts and the bias value. This makes it possible to determine both positive and negative exponent parts from the bitstream, and thus enables the generation of floating-point numbers having either a positive or a negative exponent part. Then, the bitstream can be converted into positive or negative floating-point numbers having values less than or greater than 1 in decimal notation, for example.
[0024] In a further embodiment, determining the exponent part further includes determining a difference between the number of bit - unit shifts and a bias value.
[0025] In a further embodiment, the number of bits of the bias value depends on the format of the floating - point number. In a further embodiment, the specific number of bits used to determine the mantissa part depends on the format of the floating - point number. The format of the floating - point number means a standardized specification of the floating - point number, which provides specific information about the floating - point number, such as the number of bits reserved for the exponent part and the mantissa part.
[0026] In a further embodiment, the size of the floating - point number is half - precision, single - precision, double - precision, quadruple - precision, or octuple - precision. Half - precision specifies a floating - point number with 16 - bit precision, single - precision has 32 - bit precision, double - precision has 64 - bit precision, quadruple - precision has 128 - bit precision, and octuple - precision has 256 - bit precision. The method implemented by a computer is thus suitable for generating floating - point numbers of known sizes. However, this is not limited to floating - point numbers of any one of the above - mentioned sizes, and a bit - stream can be converted into a floating - point number of any size.
[0027] In a further embodiment, the format of the floating - point number is minifloat or bfloat. And the method is suitable for converting a bit - stream into a floating - point number in a less common format. However, the method is not limited to converting the bit - stream into a floating - point number in the above - mentioned format, and it is possible to convert the bit - stream into a floating - point number having a format not listed here.
[0028] The computing system according to the present invention is suitable for executing a method implemented by a computer according to any one of the above-described embodiments. This computing system can include, for example, a central processing unit, a memory, and an image processing device. Alternatively, the computing system can be a field programmable gate array (FPGA), a hardware implementation of an application specific integrated circuit, or any other hardware / software suitable for or specially adapted to execute the method according to any of the above embodiments.
[0029] This computing system is adapted to execute a method according to any one of the above-described embodiments. By executing a method according to any one of the above-described embodiments on the computing system, the advantages of the method, such as reducing computational cost and / or energy consumption, can be obtained.
Brief Description of the Drawings
[0030]
Figure 1
Figures 2a-d
Figures 3a-c
Figure 4
Mode for Carrying Out the Invention
[0031] FIG. 1 shows a flowchart of a computer-implemented method 100 according to an embodiment of the present invention for determining a floating-point number from a bitstream. According to this flowchart, the first step of method 100 is to obtain a bitstream. This method can be executed by a general-purpose computer including a processor, a memory, and optionally a graphics processing unit. Alternatively, this method can be executed by an FPGA, a dedicated chip hardware implementation, or a computing system including other hardware / software suitable or particularly adapted to execute the methods described herein. Obtaining the bitstream can include receiving the bitstream via a receiver of the computer. For example, if the bitstream is generated outside the computer by a bitstream generator (such as a physical random bit generator), the computer may be connected to the stream generator via a USB (registered trademark) connection or another connection for data transfer. Obtaining the bitstream can alternatively include obtaining the bitstream from a bitstream generator implemented as an algorithmic bitstream generator or a dedicated physical random bit generator internal to the computer. In such a case, obtaining the bitstream can include providing the bitstream to a program or physical entity in method 100 from the algorithmic bitstream generator or the dedicated physical random bit generator.
[0032] The bitstream can be obtained continuously (e.g., one by one over time), or the bitstream can be obtained as one complete bitstream at a certain point in time.
[0033] In a preferred embodiment, the bitstream includes a stream of randomly distributed binary digits. Such a bitstream can be obtained, for example, from a random bit generator that is independently and identically distributed, such as a physical random bit generator. A physical random bit generator is, for example, two laser diodes where one laser diode is driven in a constant mode and the other laser diode is driven in a pulse mode, and the pulse mode includes driving the laser diode at a value slightly lower and slightly higher than the laser threshold in the pulse mode, thereby randomly generating laser pulses, and is an entity that utilizes an essential random process such as the phase relationship of the two laser diodes. Since the generation of laser pulses and one or more phases of this pulse are governed by quantum mechanics, the prediction of the relative phase relationship of these laser pulses with respect to the laser diode driven constantly is essentially random and unpredictable. Also, other known physical random bit generators can be used together with the present invention.
[0034] Alternatively, the bitstream can include a stream of pseudo-random digits obtained from an algorithmic random bit generator, or a stream of non-random binary digits. The resulting bitstream can also be considered to be composed of a combination of uniformly distributed random binary digits, pseudo-random binary digits, and / or non-random binary digits.
[0035] After obtaining the bitstream, the method proceeds to step 102, which includes identifying a specified position in the bitstream.
[0036] In a preferred embodiment, the specified position of the bitstream is specified as the uppermost position or the lowermost position of the bitstream. However, the specified position can be randomly determined by the user, for example, via the computing system on which the method is executed or the user interface of the computing system.
[0037] In particular, when method 100 is executed multiple times, the specified position for the first determined floating-point number may be at the first position (for example, the most significant bit of the bitstream). For the next determined floating-point number, it is possible to select 1 bit that does not belong to the multiple bits already used to determine the first floating-point number as the specified position, and so on. Preferably, for a bitstream of a given length (for example, 10 9 or 10 12 bits), by continuously executing method 100, in the bits already used to determine the floating-point number from the bitstream, a bit is not selected as the specified position.
[0038] After the specified position in the bitstream is identified, the method checks, in step 103, whether the bit at the specified position of the bitstream has a value of 1.
[0039] If the value of the bit at the specified position in the bitstream is 1, the method proceeds to step 106, including determining the exponent part of the floating-point number based on the number of bitwise shifts required to obtain the value of 1 at the specified position in the bitstream. In such a case where the bit at the specified position in the bitstream has a value of 1, since there is no need to perform a bitwise shift, the method determines the exponent part based on the initial value of the number of bitwise shifts that was initialized and executed before optionally executing step 103. In one embodiment, the initial value of the number of bitwise shifts is preferably initialized to the value of 0 in decimal. In an alternative embodiment, it is considered possible that the initial value of the bitwise shift to be executed may include a bias value.
[0040] In the alternative case, the bit at the specified position in the bitstream has a value of 0, and the method proceeds to step 104, where it enters a loop and executes the first bitwise shift of the bitstream. In a preferred embodiment, for example, in the case where the most significant bit of the bitwise shift stream is specified as the specified position of the bitstream, the bitwise shift is a left shift, or, for example, in the case where the least significant bit of the bitstream is specified as the specified position of the bitstream, the bitwise shift is a right shift. In an alternative embodiment, the specified position of the bitstream is specified at a position between the most significant bit and the least significant bit of the bitstream, and the bitwise shift can be either a left shift or a right shift.
[0041] However, once a bitwise shift is specified as a left shift or a right shift, it is preferable that any of the subsequent bitwise shifts performed to determine this floating-point number be of the same type. It should be noted that, to determine the subsequent floating-point number, the direction of the bitwise shift for determining the subsequent floating-point number may differ from the direction of the shift for determining the preceding floating-point number. In particular, in some embodiments, before performing step 102, the direction of the shift can be arbitrarily selected. In step 104, depending on whether a left shift or a right shift is used, the designated position may be set so that none of the bits intended to be used to determine the floating-point number have already been used for the preceding floating-point number.
[0042] After performing the bit-by-bit shift of the bitstream, the method proceeds to step 105 and increments by one a counter i for the number of bit-by-bit shifts to be performed. Then, the method proceeds to step 103 and checks whether the bit at the specified position of the bitstream at the current time has a value of 1. In such a case, the method proceeds to step 106 and determines the exponent part of the floating-point number based on the number i of bit-by-bit shifts performed by the method. If the bit at the specified position of the bitstream still has a value of 0, the method returns to the loop and repeats steps 103, 104, and 105 until the bit at the specified position of the bitstream has a value of 1. In some embodiments, instead of executing the loop until the bit at the specified position has a value of 1, the method can include executing the bit-by-bit shift until the number i of bit-by-bit shifts reaches a threshold value. This threshold value can vary, for example, based on the format of the floating-point number to which the bitstream is to be converted. Preferably, the threshold value identifies the number of bit-by-bit shifts that is at most equal to, or smaller than, the number of bits used for the exponent part based on the format of the floating-point number. For example, as in IEEE-754, if a 32-bit floating-point number uses 8 bits for the exponent part, the threshold value can be set to 8 or 7 or 6, and smaller values. When the threshold value is reached, the method, instead of each of the steps described above, uses a preset window according to the format of the floating-point number to obtain from the bitstream the floating-point number (i.e., the bits indicating the exponent part, the sign (optional), and the mantissa part) starting from the bit at the specified position. Thereby, it is guaranteed that the determined exponent part has a size that can be represented by the number of bits reserved for the exponent part of the floating-point number, and it is guaranteed that for a given format, at least more bit-by-bit shifts than the number of bits reserved for the exponent part are not performed.
[0043] Based on the number of bit - level shifts executed to obtain a bit having a value of 1 at the specified position of the bit stream, step 106 of determining the exponent part may further include calculating the difference between the number of the executed bit - level shifts and a bias value. This bias value can be specified, for example, by the format of the floating - point number generated by the method. Step 106 of determining the exponent part may further include increasing the number of the executed bit - level shifts by one and then calculating the difference between the value obtained accordingly and the bias value. And the obtained difference can be expressed in a form appropriate for the floating - point number. For example, when a bit - level shift of a number b is performed, the exponent part e can be calculated by e = 127-(b + 1), where b is the number of bit - level shifts for a floating - point number represented by the IEEE - 754 format and has a bias value of 127 and has a 32 - bit precision. And the exponent part can be converted into the corresponding binary digit as will be described with reference to the example shown in FIG. 4.
[0044] After step 106 of determining the exponent part, the method executes step 107 including determining the mantissa part. The mantissa part is preferably determined based on a specific number of bits of the bit stream, different from the bits used to determine the exponent part. This can ensure that there is no correlation between the exponent part and the mantissa part. This is particularly advantageous when a bit stream of uniformly distributed binary digits is changed to a sequence of floating - point numbers.
[0045] The number of bits used to determine the mantissa depends on the format of the floating-point number generated by the method. In one preferred embodiment, when the specified position of the bitstream is specified at either the most significant or the least significant position of the bitstream, the bits used to determine the mantissa are, in the case where the specified position is specified at the most significant position of the bitstream, the bits immediately following the bits used to determine the exponent part, or, in the case where the specified position is specified at the least significant position of the bitstream, the bits immediately preceding the bits used to determine the exponent part. In one more preferred embodiment, the specific number of bits used to determine the mantissa is preferably consecutive bits.
[0046] After determining the mantissa, the method proceeds to step 108 of converting the bitstream into a floating-point number using the exponent part and the mantissa determined as described above.
[0047] Method 100 can further include converting the bitstream into more than one floating-point number by continuously executing steps 102 to 108. For example, the method may identify the most significant bit of the bitstream as the first designated position in step 102. Thereafter, the method performs a certain number of left bit shifts of the bitstream until the bit at the designated position of the bitstream has a value of 1 (steps 103 to 105). Thereafter, in step 106, the method identifies the exponent part of the first floating-point number based on the number of left shifts performed. And in step 108, to obtain the floating-point number, the mantissa part of the first floating-point number is determined in step 107 based on the first specific number of consecutive bits immediately following the bits used for the determination of the exponent part. Thereafter, the method returns to step 102, identifies the second designated position of the bitstream, which may be, for example, the position in the bitstream immediately after the specific bits used for the determination of the mantissa part of the first floating-point number. And the method performs steps 103 to 108 with this new designated position to determine further floating-point numbers from the bitstream. According to the above procedure, the method can determine the exponent part and the mantissa part of further floating-point numbers from the bitstream until all bits of the bitstream are used by the method.
[0048] Optionally, the method can include determining the sign of the floating-point number. The sign bit can be identified, for example, as the bit immediately before the bit at the designated position of the bitstream. Alternatively, the sign bit can be located between the bits used for determining the exponent part and the bits used for determining the mantissa part. Although not described above, other methods of determining the sign of the floating-point number are possible.
[0049] The determination of the sign bit is not specifically shown in the flowchart of method 100, but can be provided anywhere between step 101 and step 108. For example, the sign bit can be determined by a step between obtaining the bit stream in step 101 and identifying the specified position in step 102. It may be determined after step 102 and before step 103. For example, if the bitwise shift is a left shift, the sign bit can be set as the bit immediately to the left of the specified position between step 102 and step 103. Therefore, if the bitwise shift is a right shift, the sign bit can be selected as the bit immediately to the right of the specified position.
[0050] If the sign bit is determined after the exponent part is determined but before the mantissa part is determined, it can alternatively or additionally be provided as the bit immediately (in the direction of the bitwise shift) after the bit used to determine the exponent part. If the sign bit is determined after step 107, and the sign bit may be immediately (in the direction of the bitwise shift) after the bit used to determine the exponent part and the mantissa part.
[0051] Figures 2a through 2d show different methods for determining the mantissa part and the exponent part of a bit stream according to different embodiments of the method described in FIG. 1. In these illustrated embodiments, the size of the shown bit stream (potentially a longer portion) is 29 bits and the accuracy of the mantissa part is 10 bits. It should be understood that the length of the bit stream and the number of bits used for the determination of the mantissa part are shown by way of example.
[0052] In the bit stream 201 shown in FIG. 2a, the bit at the designated position 202 of the bit stream 201 has a value of 0. According to the method, in this case, the bit-by-bit shift of the bit stream is performed at the designated position 202 of the bit stream 201 until a bit with a value of 1 is obtained. In this particular embodiment, the bit-by-bit shift is a left shift. In order to obtain a bit with a value of 1 at the designated position of the bit stream, two left shifts need to be performed, which means that three bits 203 in the bit stream are involved in determining the exponent part of the floating-point number. In this particular embodiment, the bits used to determine the mantissa part 204 are selected as 10 consecutive bits immediately after the first bit, and the first bit is immediately after the bit at the designated position of the bit stream and has a value of 1.
[0053] In an alternative embodiment in FIG. 2b, the designated position 202 coincides with the designated position in the embodiment described in detail in FIG. 2a. In this embodiment, the bit-by-bit shift is a right shift. Overall, in this example, in order to obtain a bit with a value of 1 at the designated position of the bit stream, one right shift of the bit stream needs to be performed. Next, two bits 203 of the bit stream are used in this embodiment for the determination of the exponent part. In this embodiment, the bits used for the determination of the mantissa part 204 are 10 consecutive bits immediately after the bit at the designated position 202 of the bit stream.
[0054] In an alternative embodiment in FIG. 2c, two left bit - unit shifts are performed, and ten consecutive bits 204 that are subsequent to but not immediately after the first bit are used to determine the mantissa. The first bit is subsequent to the designated position 202 of the bit stream and has a value of 1. The middle bit can be used, for example, to determine the sign of the floating - point number or, for example, to dynamically determine the designated position for determining the subsequent floating - point number. For example, based on the number of bits having a value of 0 or 1 between the bits used to determine the exponent part and the bits used to determine the mantissa (subtracted by 1 if the sign bit is obtained), it is possible to determine the distance (in bit units) from the designated position (and the position in the bit stream) to the last bit used to determine the current floating - point number for the subsequent floating - point number.
[0055] In an alternative embodiment in FIG. 2d, the bit at the designated position 202 of the bit stream has a value of 0. The bit - unit shift is specified as a left shift. Thus, in this example, at the designated position of the bit stream, two left shifts need to be performed to obtain a value of 1. In this particular embodiment, the specific number of bits used for determining the mantissa includes a first specific number of bits 206 in front of the most significant position in the bit stream and a second specific number of bits 205 subsequent to the first bit. The first bit has a value of 1 and is subsequent to the designated position in the bit stream. The first specific number of bits 206 includes, for example, 4 bits that are 2 bits away from the designated position of the bit stream. The second specific number of bits 205 includes, for example, 6 bits that are 5 bits away from the first bit used for determining the exponent part.
[0056] It is understood that when the bits 206 of the first number and the bits 205 of the second number are combined, the number of bits of the mantissa part is obtained. If the number of bits for the mantissa part is N, when a is the bits 206 of the first number and b is the bits 205 of the second number, the equation N = a + b holds. According to this, for example, the bits 205 of the second number can be obtained based on b = N - a, and the bits 206 of the first number can be determined based on, for example, the exponent part and the number of bits between the first bit of the bits 206 of the first number having a value of 0 or 1 (in the opposite direction of the bit unit shift). Therefore, a dynamic determination can be obtained for the bits used for the exponent part.
[0057] It should be understood that the embodiments shown in FIGS. 2a-d illustrate by way of example how the exponent part and the mantissa part are determined. In particular, the selection of the specified position of the bit stream is not limited to the bit position of the bit stream as selected in FIGS. 2a-d. Generally, any position in the bit stream can be specified as the specified position of the bit stream. In another embodiment not shown here, the specified position may be the most significant position, the least significant position, or any bit position between the above two positions of the bit stream.
[0058] FIGS. 3a-c show further embodiments, and by the way, each bit in the bit stream used for the determination of the sign, the mantissa part, and the exponent part is shown. Again, it should be understood that the length of the bit stream and the 10 bits used for the determination of the mantissa part are shown by way of example.
[0059] Figure 3a shows a bit stream 301, and the bit at the designated position 302 of the bit stream has a value of 0. In this embodiment, at the designated position 302 of the bit stream, two left shifts are required to obtain a bit value of 1. The sign bit 305 in this embodiment is specified as the bit immediately before the designated position 302 of the bit stream. The bits used for determining the mantissa part 304 are specified as 10 consecutive bits immediately after the first bit, and the first bit follows the designated position 302 of the bit stream and has a value of 1.
[0060] However, as shown in Figure 3b, the sign bit 305 can be positioned between the bits used for determining the exponent part 303 and the bits used for determining the mantissa part 304. In this particular embodiment, the bits used for determining the exponent part, the sign, and the mantissa part are non - consecutive and are separated by a certain number of bits.
[0061] In Figure 3c, an alternative embodiment is shown, where to obtain the bit having a value of 1 and located at the designated position 302 of the bit stream, a single right shift needs to be performed, which means that two bits 303 are used for determining the exponent part. The bits used for determining the mantissa part 304 are immediately before the bits used for determining the exponent part 302. The bit used for determining the sign 305 of the floating - point number is at a position following the designated position of the bit stream, and thus, the designated position 302 and the sign bit 305 are separated by a single bit.
[0062] Neither the direction and number of bit - by - bit shifts nor the number of bits between the bits used for the exponent part, the sign, and the mantissa part is limited. In this sense, the embodiments shown in Figures 3a - 3c are merely illustrative.
[0063] An exemplary conversion 405 that converts a bitstream 400 to a floating-point number 406, in accordance with a preferred embodiment of the method detailed in FIG. 1, is shown in FIG. 4.
[0064] In this embodiment, the bitstream 400 is converted to a single floating-point number 406 having 32-bit precision according to the IEEE-754 standard. For a single-precision floating-point number, 1 bit is reserved for the sign bit, 8 bits are reserved for the exponent part, and 23 bits are reserved for the mantissa part.
[0065] An exemplary portion of the bitstream used to determine the floating-point number by the method includes 28 bits. It should be understood that the entire bitstream can include more bits without being described here. In particular, the bitstream is not described here for simplicity of explanation, but in total is 10 9 bits or 10 12It is possible to have a size of about a bit. Therefore, the specified position 401 may be any position in the bit stream and does not necessarily have to be the most significant bit in the bit stream. Preferably, the bit stream can include randomly distributed bits, for example, bits obtained from a physical random bit generator. In this particular embodiment, the bit at the specified position 401 of the bit stream 400 has a value of 0. The sign bit 404 is specified as the bit immediately before the bit at the specified position 401 of the bit stream 400, but is not limited to the present invention, and other embodiments for determining the sign bit (such as those described in relation to FIGS. 3a - 3c) can be used. In this embodiment, the sign bit has a value of 1 in binary notation. In the example shown, it is necessary to perform three left bit - shift operations to obtain a bit with a value of 1 at the specified position 401 of the bit stream. Next, four bits 402 are used to determine the exponent part. In this embodiment, the exponent part of the floating - point number is the number of left bit - shift operations performed, here 3, incremented by 1, and then subtracted from the constant bias value of 127 specified in the single - precision format according to the IEEE - 754 standard of the floating - point number to be generated, by the value of 4 obtained as described above. Therefore, the exponent part determined by this method according to this particular embodiment corresponds to the value 123 in decimal notation, that is, it is converted to the value 1111011 in binary notation. In an 8 - bit binary notation, as the notation of the exponent part of the single - precision floating - point number generated by the method according to this embodiment, this value is read as the value 01111011 as indicated by the sign 408. In this embodiment, the mantissa part of the floating - point number is determined using 23 consecutive bits immediately after the bit of the bit stream used to determine the exponent part, as indicated by the sign 403. Therefore, the mantissa part corresponds to the value 00101001000111001111001 in binary notation.Based on the thus determined sign, exponent part, and mantissa part, the bit stream 400 is converted by the conversion 405 into a single-precision floating-point number according to the IEEE-754 standard as indicated by the sign 406. Here, the sign 407 indicates the sign bit, the sign 408 indicates the exponent part, and the sign 409 indicates the mantissa part. This number can also be represented in decimal notation 410.
[0066] In this preferred embodiment, the 28 bits, which is the number of bits consumed from the bit stream, is less than the 32 bits which is the precision of the floating-point number into which the bit stream is converted. Therefore, to obtain a 32-bit precision random floating-point number, the number of bits used from the random bit stream is less than 32 bits. By continuously executing this method, the amount of 32-bit floating-point numbers that can be obtained from a bit stream of a given length (for example, 10 9 bits) is, on average, greater than the number of floating-point numbers of the same precision that can be obtained when the bit stream is processed only by a 32-bit size continuous window, thereby enabling more random numbers to be obtained from a bit stream of a given size.
Claims
Claim 1 obtaining a bitstream (101) and converting the bitstream into a floating-point number (108), wherein the floating-point number includes an exponent part and a mantissa part, wherein the conversion includes determining the exponent part (106) of the floating-point number based on counting the number of bitwise shifts necessary to obtain a bit value of 1 at a specified position of the bitstream, wherein the conversion further includes determining the mantissa part (107) of the floating-point number based on a specific number of bits different from the bits used in determining the exponent part, a method implemented by a computer. Claim 2 The method implemented by a computer according to claim 1, wherein the specific number of bits includes bits in front of the bit at the specified position in the bitstream that have a value of 1, starting from the specified position of the bitstream, or the specific number of bits includes bits behind the first bit that have a value of 1, starting from the specified position of the bitstream. Claim 3 wherein the bitwise shift is a left shift, and the specific number of bits includes the bit immediately before the bit at the specified position in the bitstream that has a value of 1, starting from the specified position of the bitstream, or the specified number of bits includes the bit immediately after the first bit that has a value of 1, starting from the specified position of the bitstream; or wherein the bitwise shift is a right shift, and the specific number of bits includes the bit immediately after the bit at the specified position in the bitstream that has a value of 1, starting from the specified position of the bitstream, or the specified number of bits includes the bit immediately before the first bit that has a value of 1, starting from the specified position of the bitstream, the method implemented by a computer according to claim 1 or 2. Claim 4 The method implemented by a computer according to claim 1, wherein the specific number of bits includes a first specific number of bits in front of the bit at the specified position in the bitstream that have a value of 1, starting from the specified position of the bitstream, and a second specific number of bits behind the first bit. Claim 5 The method implemented by a computer according to any one of claims 1 to 4, wherein when the number of bit - unit shifts is equal to a threshold value, the value of the exponent part is a fixed value to be assigned.
6. The method implemented by a computer according to any one of claims 1 to 5, wherein the floating - point number has a sign.
7. The method implemented by a computer according to claim 6, wherein the conversion includes determining the sign of the floating - point number based on the value of a sign bit that starts from the specified position of the bit stream, has a value of 1, and is in front of the bit at the specified position or behind the first bit in the bit stream.
8. When the value of the sign bit is 0, the sign of the floating - point number is positive, and when the value of the sign bit is 1, the sign of the floating - point number is negative, or The method implemented by a computer according to claim 7, wherein when the value of the sign bit is 1, the sign of the floating - point number is positive, and when the value of the sign bit is 0, the sign of the floating - point number is negative.
9. The method implemented by a computer according to any one of claims 1 to 8, wherein determining the exponent part further includes determining the difference between the number of bit - unit shifts and a bias value.
10. The method implemented by a computer according to any one of claims 1 to 9, wherein determining the exponent part further includes, if necessary, incrementing the number of bit - unit shifts one by one.
11. The method implemented by a computer according to any one of claims 1 to 10, wherein the number of bits of the bias value depends on the format of the floating - point number.
12. The method implemented by a computer according to any one of claims 1 to 11, wherein the specific number of bits used to determine the mantissa part depends on the format of the floating - point number.
13. The method implemented by a computer according to any one of claims 1 to 12, wherein the size of the floating - point number is half - precision, single - precision, double - precision, quadruple - precision, or octuple - precision.
14. The method implemented by a computer according to any one of claims 1 to 13, wherein the format of the floating-point number is mini-float or b-float. **Claim 15** A computing system configured to execute the method implemented by a computer according to any one of claims 1 to 14.
Citation Information
Patent Citations
Hardware module for converting numbers
JP2022513300A