Computer-implemented method for converting bitstream into floating-point numbers

By dynamically determining exponential and significant numbers during the process of converting bit streams into floating-point numbers, the problem of obtaining a large number of floating-point numbers with specific precisions averaged from the bit stream is solved, and efficient energy consumption and calculation efficiency are achieved.

CN119816809APending Publication Date: 2025-04-11QUSIDE TECH SL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380061641.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-07-18
Filing Date
2023-07-18
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art is difficult to obtain a large number of floating point numbers with specific precisions averaged from the bitstream.

Method used

By obtaining a bit stream and converting it into a floating point number, the floating point number includes an exponent and a significant number, the index is determined based on the number of bits by bits required to obtain a bit value 1 at the specified position of the bit stream, and the significant number is determined based on a specific number of bits different from the bits used to determine the index.

Benefits of technology

Average obtaining a large number of floating point numbers with specific precision from the bitstream is achieved, reducing energy consumption and improving computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119816809A_ABST
    Figure CN119816809A_ABST
Patent Text Reader

Abstract

A computer-implemented method includes obtaining a bitstream and converting the bitstream to a floating-point number, where the floating-point number includes an exponent and a significant number, the converting including determining the exponent of the floating-point number based on counting a number of bit shifts required to obtain a bit value 1 at a specified location of the bitstream, the conversion further includes determining a significant number of the floating-point number based on a particular number of bits different from the bits used to determine the exponent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a computer implemented method for converting a bit stream into floating point numbers according to independent claim 1 and to a computing system adapted for converting a bit stream into floating point numbers according to independent claim 15. Background Art

[0002] Prior art

[0003] To represent decimal numbers, computers typically utilize either fixed-point or floating-point formats.

[0004] For example, a floating point number f can be represented as

[0005] f=(-1) s ·m·b e ,

[0006] Where (-1) s specifies the sign, m specifies the significant digits, b specifies the base, and e specifies the exponent of the floating point number. Since most computers today are binary machines, they handle floating point numbers using binary representation, where the base of the floating point number is given by b=2.

[0007] The most common standard used by computers to represent floating point numbers is the IEEE-754 standard. This standard specifies that floating point numbers include a single sign bit and, depending on the precision of the floating point number, a specific number of bits to represent the exponent and a specific number of bits to represent the significand. For example, a single-precision floating point number has a precision of 32 bits, where the sign bit includes a single bit, the exponent includes 8 bits, and the significand includes 23 bits.

[0008] In some cases, a computer must convert a stream of binary digits into a sequence of floating-point numbers with a certain precision. This can be the case, for example, when a computer obtains a uniformly distributed stream of random binary digits from a physical random bit generator and has the task of converting the bit stream into a uniformly distributed sequence of floating-point numbers. For example, using the representation in the IEEE-754 standard, the computer performs this task by shifting a window with the same size as the floating-point number to be generated on the bit stream in steps of the size of the floating-point number and converting a fixed number of bits located inside 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 floating-point number to be generated and in particular by the format used for the floating-point number, since this defines the size of the sliding window. Summary of the invention

[0009] Technical issues

[0010] Compared with the prior art, the technical problem solved by the present invention is to provide a method for converting a bit stream into one or more floating point numbers, wherein the method allows a large number of floating point numbers with a certain precision to be obtained on average from the bit stream.

[0011] Solution

[0012] This problem is solved by a computer implemented method according to independent claim 1 and a computer system according to independent claim 15. Preferred embodiments are provided in the dependent claims.

[0013] A computer-implemented method according to the present invention includes obtaining a bit stream and converting the bit stream into a floating point number, wherein the floating point number includes an exponent and a significand, the converting including determining the exponent of the floating point number based on counting a number of bitwise shifts required to obtain a bit value of 1 at a specified position in the bit stream, the converting also including determining the significand of the floating point number based on a specific number of bits different from the bits used to determine the exponent.

[0014] Significant figures may also be called mantissa. Generally, the two terms are used interchangeably.

[0015] For the bit stream obtained by the method implemented by a computer, it refers to a binary digit stream, each digit having a value of 0 or 1. Preferably, the bit stream includes a (uniformly distributed) random binary digit stream. This (uniformly distributed) random binary digit stream can be obtained, for example, from an independent and equally distributed random bit generator, such as a physical random bit generator including a vertical cavity surface emitting laser or a quantum phase diffusion scheme, as an example. Random binary digits can also be generated by using two lasers, one of which is operated in a constant mode, and the other is operated in a pulse mode. When the laser in the pulse mode is alternately driven below and above its laser threshold, the relative phase relationship between its laser pulse and the laser driven constantly is random, and promotes the generation of (uniformly distributed) random binary digits. However, the method is not limited to (uniformly distributed) random binary digit streams. It can also be used to convert, for example, a non-random binary digit stream, a pseudo-random binary digit stream, or a stream including any combination of random, pseudo-random and / or non-random binary digits into one or more floating point numbers.

[0016] The specified position may be any position of a bit of the bit stream. It may be the first bit of the bit stream (from the left or right) or any other bit in between. Specifically, if more than one floating point number is to be obtained from the bit stream, the specified position of the first floating point number to be determined may be the first bit of the bit stream (from the left or right), and the specified position of the subsequent floating point number to be determined may be the bit to the right or left of the last bit used to obtain the immediately preceding floating point number.

[0017] The bitwise shift may include a left shift or a right shift, and may preferably include a single one-bit shift per bitwise shift, although shifts of more than one bit per shift are also encompassed by the present disclosure. In one embodiment, the bitwise shifts performed by the method to obtain a bit value of 1 at a specified position in the bit stream are of the same type. This means, for example, that when the first bitwise shift performed by the method is a right shift, all subsequent bitwise shifts performed to obtain a bit value of 1 at a specified position in the bit stream are also right shifts. Alternatively, when the first bitwise shift of the bit stream is a left shift, all subsequent bitwise shifts performed to obtain a bit value of 1 at a specified position in the bit stream are also left shifts.

[0018] Optionally, the method may include a rearrangement of the bit stream, which may be performed after obtaining the bit stream and before determining the exponent. Such rearrangement of the bit stream may include a random rearrangement, a pseudo-random rearrangement or a non-random rearrangement, such as, for example, a hash operation. By rearranging the bit stream in the above manner, additional security aspects may be achieved in the method, since the bit stream used to determine the exponent and the significand is different from the bit stream originally obtained by the method. This may be relevant, for example, when the bit stream is a uniformly distributed random bit stream and, for example, is used to generate a random password.

[0019] Instead of using a fixed number of bits of a bit stream to determine the exponent of a floating point number, the method according to the present invention dynamically determines the number of bits of the bit stream required for the exponent of a specified floating point number by implementing a bitwise shift of the bit stream until a bit with a value of 1 is obtained at a specified position of the bit stream. Since the probability of a bit with a value of 1 is 50% at least for a uniformly distributed random bit stream, the number of shifts required starting from the specified position will usually be 0 (in the case where the bit at the specified position is already 1), and in most cases (87.5%) it will be 1 or 2. For example, this bit is used as the most significant bit for determining the exponent of a 32-bit floating point number, thus reducing the number of bits required for the exponent by at least 5 on average in most cases. Thus, compared to the prior art, the number of bits used to obtain, for example, a 32-bit floating point number is significantly reduced, thereby allowing more floating point numbers to be obtained from a bit stream of a given length without reducing the precision of these floating point numbers.

[0020] Advantageously, the method also reduces energy consumption, since generating a particular number of floating point numbers requires, on average, a smaller number of bits from a bit source, which may be, for example, a physical random bit generator. The fewer bits that need to be generated, the less energy that needs to be consumed by the physical random bit generator, and therefore the less energy required to generate the floating point numbers.

[0021] As the designated position of the bit stream, any bit position of the bit stream can be designated. The designated position of the bit stream can be, for example, the most significant position (or the leftmost bit) of the bit stream or the least significant position (or the rightmost bit) of the bit stream. However, any other bit position between the most significant position and the least significant position of the bit stream can also be selected as the designated position of the bit stream.

[0022] In one embodiment, the specific number of bits is included in the bits before the bits at the specified position of the bit stream, or the specific number of bits is included in the bits after the first bit with a value of 1 starting from the specified position of the bit stream. This ensures that the specific number of bits used to determine the significant digit is different from the bits used to determine the exponent. Therefore, there is no correlation between the exponent and the significant digit of the floating point number, which is relevant, for example, when a uniformly distributed random binary digit stream should be converted into a uniformly distributed floating point number stream. The specific number of bits before the bits at the specified position can be a sequence of continuous bits; however, a sequence of non-continuous bits is also conceivable. This is also true for the specific number of bits after the first bit with a value of 1 starting from the specified position of the bit stream.

[0023] In another embodiment, the bitwise shift may be a left shift, and the specific number of bits includes the bits immediately before the bit at the specified position of the bit stream, or the specific number of bits includes the bits immediately after the first bit with a value of 1 starting from the specified position of the bit stream. This is conceivable, for example, when the specified position of the bit stream is indicated as the most significant position of the bit stream. The bitwise shift may also be a right shift, and the specific number of bits includes the bits immediately after the bit at the specified position of the bit stream, or the specific number of bits includes the bits immediately before the first bit with a value of 1 starting from the specified position of the bit stream. This may be the case, for example, when the specified position of the bit stream is selected as the least significant position of the bit stream.

[0024] In an alternative embodiment, the specific number of bits includes a first specific number of bits before the bit at the specified position of the bit stream and a second specific number of bits after the first bit of value 1 starting from the specified position of the bit stream. For example, this allows efficient use of the bits of the bit stream for a case where the specified position is close to the most significant position of the bit stream, and bits before the bit at the specified position of the bit stream, or bits after the first bit of value 1 after the bit at the specified position of the bit stream will not be sufficient to indicate a significant digit of the floating point number. This may be advantageous in embodiments where the specified position is randomly selected.

[0025] In another embodiment, when the number of bit shifts is equal to the threshold, the value of the exponent is a given fixed value. In this way, it is ensured that even when the number of bit shifts required to obtain a bit value of 1 at a specified position of the bit stream is too large to be represented by the number of bits of the floating point number reserved for the exponent, or when the bit stream will only include bits with a value of 0, the exponent can be generated by this method. The threshold value can be, for example, equal to the number of bits used for the exponent in a given floating point format. For example, the threshold value can be 8. The given fixed value can be selected arbitrarily and can be defaulted to 1 or 0. Alternatively, if the threshold value is reached, the given fixed value can be a randomly determined value determined independently of the bit stream itself, and is therefore also regarded as a given fixed value in the present disclosure. Alternatively, when the threshold value is reached, the value of the exponent can be fixed to its lowest possible value by default, which facilitates the generation of subnormal floating point numbers.

[0026] In another embodiment, the floating point number includes a sign. Including a sign doubles the range of possible floating point numbers that can be generated from the bit stream and also allows negative floating point numbers to be generated, which can be advantageous for certain embodiments of the method, for example, when a subsequent process requires a random number in the range [-1; 1] or any other range that includes positive and negative numbers.

[0027] In another embodiment, the conversion includes determining the sign of the floating point number based on the value of the sign bit before the bit at the specified position of the bit stream or after the first bit with a value of 1 starting from the specified position of the bit stream. This ensures that the bit used to determine the sign of the floating point number is different from the bit used to determine the exponent of the floating point number. However, it does not determine whether the bit used to determine the sign of the floating point number has been used to determine the significant digit. For some embodiments, it may be preferred that the sign bit is also different from the bit used to determine the significant digit. For example, this may be the case when a bit stream of uniformly distributed binary digits should be converted into a sequence of uniformly distributed floating point numbers, because in this special case, there should be no correlation between the sign of the floating point number and the significant digit.

[0028] In another embodiment, the sign of the floating point number is positive when the value of the sign bit is 0, and the sign of the floating point number is negative when the value of the sign bit is 1, or, wherein the sign of the floating point number is positive when the value of the sign bit is 1, and the sign of the floating point number is negative when the value of the sign bit is 0. Thus, the method also provides a second alternative representation of the sign bit compared to the IEEE-754 standard.

[0029] In another embodiment, determining the exponent further comprises determining the difference between the bitwise shift number and the bias value. This allows both positive and negative exponent values ​​to be determined from the bitstream, which in turn allows for the generation of floating point numbers with positive or negative exponents. Thus, for example, the bitstream can be converted to a positive or negative floating point number with a value less than or greater than 1 in decimal notation.

[0030] In another embodiment, determining the exponent further comprises increasing the number of bitwise left shifts required by one.

[0031] In another embodiment, the number of bits of the bias value may depend on the format of the floating point number. In another embodiment, the specific number of bits used to determine the significant digits may depend on the format of the floating point number. The format of a floating point number refers to a standardized specification of a floating point number that provides different information about the floating point number, such as the number of bits reserved for its exponent or significant digits.

[0032] In another embodiment, the size of the floating point number is half, single, double, quadruple or octupled. Half refers to a floating point number with 16 bits of precision, single is 32 bits of precision, double is 64 bits of precision, quadruple is 128 bits of precision, and octupled is 256 bits of precision. Therefore, the computer-implemented method is suitable for generating floating point numbers of known sizes in general. However, it is not limited to floating point numbers with one of the above-mentioned specified sizes, because it can convert the bit stream into a floating point number of any size.

[0033] In another embodiment, the format of the floating point number is minifloat or bFloat. Therefore, the method is also suitable for converting a bit stream into a floating point number of a less common format. However, it is not limited to generating floating point numbers in the above formats, and the bit stream can also be converted into a floating point number having a format not explicitly listed here.

[0034] The computing system according to the present invention is suitable for performing a computer-implemented method according to any of the above-described embodiments. The computing system may, for example, include a central processing unit, a memory, and a graphics processing unit. Alternatively, the computing system may include a field programmable gate array (FPGA), a dedicated chip hardware implementation, or any other hardware / software suitable or specifically adapted to perform a method according to any of the above-described embodiments.

[0035] The computing system is suitable for implementing the method according to any of the above embodiments.Running the method according to any of the above embodiments on a computing system allows to obtain the advantages of the method, including for example saving computing costs and / or energy consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A flow chart of a method according to one embodiment is shown.

[0037] Figure 2 a- Figure 2 d illustrates a bit stream, where the bits used to determine the significand and the exponent are indicated according to different embodiments.

[0038] Figure 3 a- Figure 3c shows a bit stream, where the bits used to determine the sign, significand and exponent according to different embodiments are indicated.

[0039] Figure 4 The conversion of a bit stream to a single precision floating point number according to an embodiment is illustrated. DETAILED DESCRIPTION

[0040] Figure 1 A flow chart is shown, which illustrates a computer-implemented method 100 for determining a floating point number according to an embodiment of the present invention based on a bitstream. According to the flow chart, the first step 101 of method 100 is to obtain a bitstream. The method can be implemented by a general-purpose computer, which includes a processor and a memory and optionally includes a graphics processing unit. Alternatively, the method can be performed on a computing system including an FPGA, a dedicated chip hardware implementation, or any other hardware / software suitable for or specifically suitable for performing the method described herein. The acquisition of the bitstream can include receiving the bitstream via a receiver of the computer. For example, if the bitstream is generated by a bitstream generator (such as a physical random bit generator) outside the computer, the computer can be connected to the bitstream generator via a USB connection or a similar connection for data transmission. The acquisition of the bitstream can alternatively include obtaining the bitstream from a bitstream generator resident inside the computer, and the bitstream generator can be implemented as an algorithmic bitstream generator or a dedicated physical random bit generator. In this case, the acquisition of the bitstream can include providing the bitstream from the algorithmic bitstream generator or the dedicated physical random bit generator to a program or physical entity that performs the method 100.

[0041] The bitstream may be obtained continuously (ie, bit by bit over time), or the bitstream may be obtained as a complete bitstream at one point in time.

[0042] In a preferred embodiment, the bit stream comprises a uniformly distributed stream of random binary digits. For example, such a bit stream may be obtained from an independent and equally distributed random bit generator, such as a physical random bit generator. A physical random bit generator is an entity that utilizes an inherently random process, such as, for example, the phase relationship of two laser diodes, one of which is driven in a constant mode and the other is driven in a pulsed mode, wherein the pulsed mode comprises driving the laser diode shortly below the laser threshold and shortly above the laser threshold, thereby randomly generating laser pulses. Since the generation of laser pulses and the phase of the pulses are governed by the rules of quantum mechanics, predicting the relative phase relationship of the laser pulses relative to the constantly driven laser diode is inherently random and unpredictable. In addition, there are other physical random bit generators that can be used with the present invention.

[0043] Alternatively, the bit stream may also include a pseudo-random digit stream or a non-random binary digit stream, which may be obtained from an algorithmic random bit generator. It is also conceivable that the obtained bit stream includes a combination of uniformly distributed random binary digits, pseudo-random binary digits and / or non-random binary digits.

[0044] After obtaining the bitstream, the method proceeds to step 102, which includes indicating a designated location of the bitstream.

[0045] In a preferred embodiment, the specified position of the bitstream is indicated as the most significant position or the least significant position of the bitstream. However, the specified position may also be indicated as any other position of the bitstream, which may be randomly determined, for example, by a computing system on which the method is implemented, or by a user via a user interface of the computing system.

[0046] Specifically, if method 100 is executed more than once, the designated position of the first floating point number to be determined may be at the first position (e.g., the most significant bit of the above bit stream). For subsequent floating point numbers to be determined, a bit that is not part of the bit used to determine the first floating point number may be selected as the designated position, and so on. Preferably, before continuing to execute the given length (e.g., 10 9 or 10 12 When the method 100 is used to determine a bit stream of a floating point number based on the bit stream, there is no selected designated position at the bit that has been used to determine the floating point number based on the bit stream.

[0047] After the designated position of the bit stream has been designated, the method checks in step 103 whether the bit at the designated position of the bit stream has a value of 1.

[0048] In the event that the value of the bit at the specified position of the bit stream is 1, the method proceeds to step 106, which includes determining an exponent of the floating point number based on the number of bitwise shifts required to obtain the value 1 at the specified position of the bit stream. In the present case, where the value of the bit at the specified position of the bit stream is 1, no bitwise shift needs to be performed, and the method determines the exponent based on an initial value of the number of bitwise shifts performed, which initial value may optionally be initialized prior to performing step 103. In one embodiment, the initial value of the bitwise shift performed is preferably initialized to a decimal value of 0. In an alternative embodiment, it is contemplated that the initial value of the bitwise shift performed may include a bias value.

[0049] In an alternative case, where the value of the bit at the designated position of the bit stream is 0, the method enters a loop and continues to execute step 104, which includes performing a first bitwise shift of the bit stream. In a preferred embodiment, the bitwise shift is a left shift, such as when the most significant position of the bit stream is indicated as the designated position of the bit stream, or a right shift, such as when the least significant position of the bit stream is indicated as the designated position of the bit stream. In an alternative embodiment, where the designated position of the bit stream is indicated as being somewhere between the most significant position and the least significant position of the bit stream, the bitwise shift can be a left shift or a right shift.

[0050] However, once the bitwise shift is indicated as a left shift or a right shift, any subsequent bitwise shift implemented to determine the floating-point number is preferably of the same type. It should be noted that, in order to determine the subsequent floating-point number, the direction of the bitwise shift may be different from the direction of the shift used to determine the previous floating-point number. Specifically, in some embodiments, the direction of the shift may be randomly selected before performing step 102. Depending on whether to use a left shift or a right shift in step 104, a designated position may be set to ensure that the position used for any previous floating-point number is not used to determine the floating-point number.

[0051] After performing the bitwise shift of the bitstream, the method proceeds to step 105, and a counter i of the number of bitwise shifts implemented can be increased by one. The method then proceeds to step 103, and checks whether the bit at the specified position of the bitstream now has a value of 1. If so, the method proceeds to step 106, and determines the exponent of the floating point number based on the bitwise shift number i implemented 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 implements steps 103, 104 and 105 again until a bit with a value of 1 is obtained at the specified position of the bitstream. In some embodiments, the method may include implementing the bitwise shift until the bitwise shift number i reaches a threshold, rather than performing a loop until a bit with a value of 1 is obtained at the specified position. For example, the threshold can be based on the format of the floating point number to which the bitstream should be converted. Preferably, the threshold specifies a bitwise shift number that is at most equal to the number of bits that will be used for the exponent according to the format of the floating point number, or even smaller. For example, if a 32-bit floating point number uses 8 bits for the exponent as in IEEE-754, the threshold value may be set to 8 or 7 or 6 or a smaller value. If the threshold value is reached, the method may include using a predefined window corresponding to the format of the floating point number instead of the above steps to obtain the floating point number (i.e., the bits representing the exponent, the sign (optional), and the significant digits) from the bit stream starting from the bit at the specified position. In this way, it is ensured that the determined exponent has a size that can be represented by the number of bits of the floating point number reserved for the exponent, while ensuring that the number of bitwise shifts performed is at least no more than the number of bits reserved for the exponent with the given format.

[0052] Determining the exponent 106 based on the number of bitwise shifts performed to obtain a bit with a value of 1 at a specified position in the bitstream may further include calculating the difference between the number of bitwise shifts implemented and a bias value. For example, the bias value may be specified by the format of the floating point number to be generated by the method. Determining the exponent 106 may also include increasing the number of bitwise shifts implemented by one, and then calculating the difference between the value thus obtained and the bias value. The obtained difference may then be represented in a form suitable for a floating point number. For example, if b bitwise shifts are performed, then for a floating point number represented by the IEEE-754 format and having 32 bits of precision and a bias value of 127, the exponent e may be calculated as e=127-(b+1), where b is the number of bitwise shifts. The exponent may then be converted to a corresponding binary representation, as shown in reference Figure 4 As explained by the examples in .

[0053] After determining the exponent 106, the method implements step 107, which includes determining the significant digit. The significant digit is determined based on a specific number of bits of the bit stream, which is preferably different from the bits used to determine the exponent. In this way, it can be ensured that there is no correlation between the significant digit and the exponent. This is particularly advantageous when a bit stream of uniformly distributed binary digits is to be converted into a sequence of floating point numbers.

[0054] The number of bits used to determine the significand may depend on the format of the floating point number to be generated by the method. In a preferred embodiment, where the specified position of the bit stream is indicated as the most or least significant position of the bit stream, the bits used to determine the significand are the bits immediately following the bits used to determine the exponent in the case where the specified position is the most significant position of the bit stream, or the bits used to determine the significand are the bits directly preceding the bits used to determine the exponent in the case where the specified position of the bit stream is indicated as the least significant position of the bit stream. In a more specific embodiment, the specific number of bits used to determine the significand are preferably consecutive bits.

[0055] After determining the significand, the method continues with the step of converting the bit stream to a floating point number 108 by using the previously determined exponent and significand.

[0056] Method 100 may also include converting a bit stream into more than one floating point number by continuously performing steps 102 to 108. For example, the method may indicate the first specified position as the most significant position of the bit stream in step 102. Afterwards, the method implements multiple bitwise left shifts of the bit stream until a position with a value of 1 is obtained at the specified position of the bit stream (steps 103 to 105). Afterwards, the method specifies the exponent of the first floating point number based on the number of left shifts implemented in step 106. Then, in step 107, the significant digits of the first floating point number are determined based on the first specific number of continuous bits (directly) after the bit for determining the exponent, so as to obtain the floating point number in step 108. Afterwards, the method returns to step 102 and indicates a second specified position of the bit stream, which may be, for example, a position of the bit stream directly after certain bits for determining the significant digits of the first floating point number. Then, the method implements steps 103 to 108 using the new specified position to determine another floating point number according to the bit stream. According to the process detailed above, the method can determine the exponent and significand of further floating point numbers from the bit stream until, for example, all bits of the bit stream are used by the method.

[0057] Optionally, the method may also include determining the sign of the floating point number. For example, the sign bit may be specified as the bit immediately preceding the bit at the specified position of the bit stream. Alternatively, the sign bit may also be located between the bit used to determine the exponent and the bit used to determine the significant digit. In addition, other ways of determining the sign of the floating point number that have not been explicitly mentioned above are also possible.

[0058] The determination of the sign bit is not specifically shown in the flowchart of method 100, but may be provided between any of steps 101 to 108. For example, the sign bit may be determined by a step between obtaining the bit stream in step 101 and indicating the designated position in step 102. The sign bit may also be determined after step 102 and before step 103. For example, if the bitwise shift is a left shift, the sign bit may be set to the bit immediately to the left of the designated position between steps 102 and 103. Correspondingly, if the bitwise shift is a right shift, the sign bit may be selected to be the bit immediately to the right of the designated position.

[0059] If the sign bit is determined after the exponent has been determined but before the significand has been determined, it may alternatively or additionally be provided that the sign bit is the bit immediately following (in the direction of the bit shift) the bit used to determine the exponent. If the sign bit is determined after step 107, the sign bit may be the bit immediately following (in the direction of the bit shift) the bit used to determine the significand and the exponent.

[0060] Figure 2 a to Figure 2 d Instructions according to Figure 1Different embodiments of the method described in the embodiment of the invention are different ways of determining the significand and the exponent from the bit stream. In these exemplary embodiments, the size of the bit stream shown (possibly a longer part) is 29 bits, and the precision of the significand is 10 bits. The length of the bit stream and the number of bits used to determine the significand must be understood as exemplary.

[0061] exist Figure 2 In the bit stream 201 shown in a, the value of the bit at the specified position 202 of the bit stream 201 is 0. According to the method, in this case, a bitwise shift of the bit stream is implemented until a bit with a value of 1 is obtained at the specified position 202 of the bit stream 201. In this particular embodiment, the bitwise shift is a left shift. In order to obtain a bit value of 1 at the specified position of the bit stream, two left shifts must be implemented, meaning that three bits 203 of the bit stream are involved in determining the exponent of the floating point number. In this particular embodiment, the bits used to determine the significand 204 are selected as the ten consecutive bits after the first bit with a value of 1 directly after the bit at the specified position of the bit stream.

[0062] exist Figure 2 An alternative embodiment is illustrated in b, in which the designated position 202 is Figure 2 a. In this embodiment, the bitwise shift is a right shift. In general, in this example, to obtain a bit value of 1 at the specified position of the bit stream, a right shift of the bit stream must be performed. Therefore, in this embodiment, two bits of the bit stream 203 are used to determine the exponent. In this embodiment, the bits used to determine the significand 204 are ten consecutive bits directly after the bit at the specified position 202 of the bit stream.

[0063] As Figure 2 c, in which two bitwise left shifts are performed, ten consecutive 204 bits after the first bit having a value of 1 after the specified position 202 of the bit stream but not directly after the first bit are used to determine the significant digit. The intermediate bits can be used, for example, to determine the sign of the floating point number, or, for example, to dynamically determine the specified position for determining the subsequent floating point number. For example, based on the number of bits with a value of 0 or 1 between the bit for determining the exponent and the bit for determining the significant digit (if the sign bit is obtained, it is reduced by 1), the distance (in bits) from the specified position of the subsequent floating point number (and therefore its position in the bit stream) to the last bit for determining the current floating point number can be determined.

[0064] exist Figure 2d, the value of the bit at the specified position 202 of the bit stream is 0. The bitwise shift is specified as a left shift, where, in this example, two left shifts must be performed to obtain a value of 1 at the specified position of the bit stream. In this particular embodiment, the specific number of bits used to determine the significand includes a first specific number of bits 206 before the most significant position of the bit stream and a second specific number of bits 205 after the first bit, which is after the bit at the specified position of the bit stream and has a value of 1. The first specific number of bits 206 includes a number of, for example, four bits, which can be separated from the specified position of the bit stream by two bits. The second specific number of bits 205 includes, for example, a number of 6 bits, which can be separated from the first bit used to determine the exponent by a number of 5 bits.

[0065] It can be understood that the first specific number of bits 206 and the second specific number of bits 205 add up to the number of bits of the significant digit. Assuming that the number of bits of the significant digit is N, the relationship N=a+b holds, where a is the first digit 206, and b is the second digit 205. Based on this, for example, the second digit 205 can be determined based on b=Na, and the first digit 206 can be determined, for example, based on the number of bits with a value of 0 or 1 between the exponent and the first bit of the first digit 206 (in the direction opposite to the bitwise shift). The bits used for the exponent can thus be dynamically determined.

[0066] exist Figure 2 a- Figure 2 The embodiments presented in d must be understood as exemplary illustrations of how the exponent and the significant figures can be determined. In particular, the selection of the designated position of the bit stream is not limited to the following. Figure 2 a- Figure 2 d. Generally, any position of the bit stream can be indicated as the designated position of the bit stream. In another embodiment not explicitly illustrated here, the designated position can be the most significant position, the least significant position, or any bit position between the two just mentioned positions of the bit stream.

[0067] Figure 3 a- Figure 3 c illustrates a further exemplary embodiment, in which the bits of the bit stream used to determine the sign, the significand and the exponent are indicated. Likewise, the length of the bit stream and the number of ten bits used to determine the significand must be understood as exemplary.

[0068] Figure 3301 shows a bit stream 301 in which the bit at the designated position 302 of the bit stream has a value of 0. In this embodiment, two left shifts are required to obtain a bit value of 1 at the designated position 302 of the bit stream. In this embodiment, a sign bit 305 is indicated as the bit immediately before the designated position 302 of the bit stream. The bits used to determine the significand 304 are specified as the ten consecutive bits after the first bit having a 1 immediately after the designated position 302 of the bit stream.

[0069] However, if Figure 3 As shown in FIG. 1 b, a sign bit 305 may also be located between the bits used to determine the exponent 303 and the bits used to determine the significand 304. In this particular embodiment, the bits used to determine the exponent, sign, and significand are not consecutive, but are separated by a specific number of bits.

[0070] exist Figure 3 c illustrates an alternative embodiment in which a single right shift must be performed in order to obtain a bit with a value of 1 at the specified position 302 of the bit stream, meaning that two bits 303 are used to determine the exponent. The bits used to determine the significand 304 are directly before the bits used to determine the exponent 302. The bit used to determine the sign 305 of the floating point number is located at a position after the specified position of the bit stream, with a single bit separating the specified position 302 and the sign bit 305.

[0071] There are no restrictions on the direction and number of bitwise shifts performed, nor on the number of bits used for the exponent, sign, and significand. Figure 3 a to Figure 3 The embodiment of c is merely exemplary in this respect.

[0072] exist Figure 4 The diagram shows the Figure 1 An example conversion 405 of a bit stream 400 to a floating point number 406 of a preferred embodiment of the method detailed in FIG.

[0073] In this embodiment, the bit stream 400 is converted into a single floating point number 406 with a precision of 32 bits according to the IEEE-754 standard. In the case of a single precision floating point number, 1 bit is reserved for the sign bit, 8 bits are reserved for the exponent, and 23 bits are reserved for the significand.

[0074] An exemplary portion of the bitstream used by the method to determine a floating point number includes 28 bits. It will be appreciated that the entire bitstream is not depicted here and may include more bits. Specifically, the total size of the bitstream may be approximately 10 9 or 10 12The designated position 401 may be any position within the bit stream, not necessarily the most significant bit of the bit stream. Preferably, the bit stream comprises uniformly distributed random bits, which may be obtained, for example, from a physical random bit generator. In this particular embodiment, the value of the bit at the designated position 401 of the bit stream 400 is 0. The sign bit 404 is indicated as the bit immediately preceding the bit at the designated position 401 of the bit stream 400, but is not limited to the present invention, and any other embodiment for determining the sign bit (such as with respect to Figure 3 a to Figure 3 c described embodiment). In this embodiment, the sign bit has a value of 1 in the binary representation. In order to obtain a bit with a value of 1 at a specified position 401 of the bit stream, three bitwise left shifts must be implemented in the example shown. Therefore, four bits 402 are used to determine the exponent. In this embodiment, the exponent of the floating point number is then determined by increasing the number of bitwise left shifts implemented (which is equal to three) by one and subtracting the value 4 thus obtained from the constant bias value 127, as specified by the single-precision format according to the IEEE-754 standard for the floating point number to be generated. The exponent determined by the method according to this particular embodiment therefore corresponds to a value of 123 in decimal notation, which is converted into a value of 1111011 in binary representation. In an 8-bit binary representation as used to represent the exponent of the single-precision floating point number to be generated by the method according to this embodiment, the value is read as 01111011, as shown in 408. In this embodiment, the significant digits of the floating point number are determined by using 23 consecutive bits immediately following the bits of the bit stream used to determine the exponent, as shown in 403. Thus, the significand corresponds to the value 00101001000111001111001 in binary representation. Based on the sign, exponent, and significand thus determined, the bit stream 400 is then converted 405 to a single precision floating point number in IEEE-754 representation 406. Here, term 407 represents the sign bit, term 408 represents the exponent, and term 409 represents the significand. This number can also be represented in decimal representation 410.

[0075] In this preferred embodiment, the number of bits consumed from the bit stream is 28 bits, which is less than the 32-bit precision of the floating point to which the bit stream is converted. Therefore, the number of bits used to obtain a random floating point number with 32-bit precision from the random bit stream is less than 32 bits. By continuously implementing this method, a random floating point number with a given length (e.g., 10 9 The amount of 32-bit floating point numbers obtained from a bitstream of a given size is on average greater than the number of floating point numbers with the same precision that could be obtained if the bitstream were processed only through consecutive 32-bit sized windows, thereby allowing more random numbers to be obtained from a bitstream of a given size.

Claims

1. A computer-implemented method comprising obtaining a bit stream (101) and converting the bit stream into a floating point number (108), wherein the floating point number comprises an exponent and a significand, the converting comprising determining the exponent of the floating point number based on counting the number of bitwise shifts required to obtain a bit value of 1 at a specified position of the bit stream (106), the converting further comprising determining the significand of the floating point number based on a specific number of bits different from the bits used to determine the exponent (107).

2. A computer-implemented method according to claim 1, wherein the specific number of bits includes bits before the bit at the specified position of the bit stream, or the specific number of bits includes bits after a first bit with a value of 1 starting from the specified position of the bit stream.

3. The computer-implemented method of claim 1 or 2, wherein: the bitwise shift is a left shift, and wherein the particular number of bits includes bits immediately before the bit at the specified position of the bit stream, or the particular number of bits includes bits immediately after the first bit having a value of 1 starting from the specified position of the bit stream; or wherein the bitwise shift is a right shift, and wherein the specific number of bits includes bits immediately following the bit at the specified position of the bit stream, or wherein the specific number of bits includes bits immediately preceding the first bit having a value of 1 starting from the specified position of the bit stream.

4. The computer-implemented method of claim 1 , wherein the specific number of bits comprises a first specific number of bits before the bit at the specified position of the bit stream, and a second specific number of bits after the first bit having a value of 1 starting from the specified position of the bit stream.

5. A computer-implemented method according to any one of claims 1 to 4, wherein in case the bitwise shift number is equal to a threshold value, the value of the exponent is a given fixed value.

6. The computer-implemented method of any one of claims 1 to 5, wherein the floating point number includes a sign.

7. The computer-implemented method of claim 6, wherein the converting comprises determining the sign of the floating-point number based on a value of a sign bit preceding the bit at the specified position of the bit stream or following the first bit having a value of 1 starting from the specified position of the bit stream.

8. The computer-implemented method of claim 7 , wherein the sign of the floating-point number is positive if the value of the sign bit is 0, and the sign of the floating-point number is negative if the value of the sign bit is 1, or wherein the sign of the floating-point number is positive if the value of the sign bit is 1, and the sign of the floating-point number is negative if the value of the sign bit is 0.

9. The computer-implemented method of any one of claims 1 to 8, wherein: Determining the exponent also includes determining a difference between the bitwise shift number and a bias value.

10. The computer-implemented method of any one of claims 1 to 9, wherein determining the exponent further comprises increasing the required number of bitwise shifts by one.

11. A computer-implemented method 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 computer-implemented method of any one of claims 1 to 11, wherein the particular number of bits used to determine the significant digit depends on the format of the floating point number.

13. The computer-implemented method of any one of claims 1 to 12, wherein the size of the floating point number is half, single, double, quadruple, or octave.

14. The computer-implemented method of any one of claims 1 to 13, wherein the format of the floating point number is minifloat or bFloat.

15. A computing system adapted to perform a computer-implemented method according to any one of claims 1 to 14.