ieee-754

Converting Float32Array to Uint8Array while Preserving IEEE 754 Representation

ⅰ亾dé卋堺 提交于 2019-12-20 06:29:14
问题 I have a float32Array from decodeAudioData method, which I want to convert it to Uint8Array while preserving the float32 IEEE 754 audio data . So far I tried, var length = float32Array.length; var emptyBuffer = new ArrayBuffer(length * 4); var view = new DataView(emptyBuffer); for (var i = 0; i < length; i++) { view.setFloat32(i * 4, float32Array[i], true); } var outputArray = new Uint8Array(length); for (var j = 0; j < length; j++) { outputArray[j] = view.getUint8(j * 4); } return

How is float variable auto-promoted to double type?

蓝咒 提交于 2019-12-20 02:54:34
问题 I know in C and Java, float's underlying representation is IEEE754-32, double is IEEE754-64. In expressions, float will be auto-promoted to double . So how? Take 3.7f for example. Is the process like this? 3.7f will be represented in memory using IEEE754. It fits in 4 bytes. During calculation, it may be loaded into a 64-bit register (or whatever 64-bit place), turning the 3.7f into IEEE754-64 represent. 回答1: It is very implementation-dependent. For one example, on x86 platform the set of FPU

Why do we need IEEE 754 remainder?

时间秒杀一切 提交于 2019-12-19 19:46:08
问题 I just read this topic (especially the last comments). Then I was wondering, why we actually need this was of giving the remainder. But it seems, that not many people "on google" were interested in that before... 回答1: If you're looking for reasons why you would want it, one is for what is known as "range reduction" Let's say you want sind function for computing the sine of an argument in degrees. A naive way to do this would be sind(x) = sin(x*pi/180) However pi here is not the true

What is overflow and underflow in floating point

为君一笑 提交于 2019-12-19 11:28:00
问题 I feel I don't really understand the concept of overflow and underflow . I'm asking this question to clarify this. I need to understand it at its most basic level with bits. Let's work with the simplified floating point representation of 1 byte - 1 bit sign, 3 bits exponent and 4 bits mantissa: 0 000 0000 The max exponent we can store is 111_2=7 minus the bias K=2^2-1=3 which gives 4 , and it's reserved for Infinity and NaN . The exponent for max number is 3 , which is 110 under offset binary

Convert IEEE float hex to decimal?

 ̄綄美尐妖づ 提交于 2019-12-19 10:18:30
问题 IF I have a IEEE float hex 42F6E979, how do I convert it to decimal? I believe the decimal representation is = 123.456001 回答1: (Most) assembly language doesn't really enforce types very strongly, so you can just initialize a location with that value, and then treat/use it as a float. The easiest way to convert is usually something like: .data myfloat dd 042F6E979H mydec db 10 dup(?) .code mov ebx, offset mydec fld myfloat fbstp [ebx] This actually produces binary coded decimal, so you have to

Exact textual representation of an IEEE “double”

…衆ロ難τιáo~ 提交于 2019-12-19 07:09:33
问题 I need to represent an IEEE 754-1985 double (64-bit) floating point number in a human-readable textual form, with the condition that the textual form can be parsed back into exactly the same (bit-wise) number. Is this possible/practical to do without just printing the raw bytes? If yes, code to do this would be much appreciated. 回答1: Best option: Use the C99 hexadecimal floating point format: printf("%a", someDouble); Strings produced this way can be converted back into double with the C99

IBM to IEEE floating point conv

妖精的绣舞 提交于 2019-12-19 06:53:45
问题 Is there any standard method in java to convert IBM 370(in the form of bytes) to IEEE format.?Any algorithm for the conversion would help.. I tried writing a java code..But i fail to understand where do i go wrong. When i give the input as -2.000000000000000E+02, i'm getting the value as -140.0 in IEEE format. and in othercase when i give the input as 3.140000000000000E+00 i'm getting the value as 3.1712502374909226 in IEEE format Any help on this would be highly appreciated private void

IBM to IEEE floating point conv

天涯浪子 提交于 2019-12-19 06:51:32
问题 Is there any standard method in java to convert IBM 370(in the form of bytes) to IEEE format.?Any algorithm for the conversion would help.. I tried writing a java code..But i fail to understand where do i go wrong. When i give the input as -2.000000000000000E+02, i'm getting the value as -140.0 in IEEE format. and in othercase when i give the input as 3.140000000000000E+00 i'm getting the value as 3.1712502374909226 in IEEE format Any help on this would be highly appreciated private void

Sorting floating-point values using their byte-representation

寵の児 提交于 2019-12-19 02:06:55
问题 If have an 8-byte section of data and write a double-precision floating-point value to it, under what conditions will comparison by numerical comparison and lexicographic sorting of the bytes agree? Current theory: positive, big-endian I believe that if the number is positive, and the representation is big-endian, then numerical ordering of the floating-point values will match the lexicographic ordering of the bytes. The idea is that it would first sort on the exponent, then on the mantissa.

subnormal IEEE 754 floating point numbers support on iOS ARM devices (iPhone 4)

五迷三道 提交于 2019-12-18 19:21:33
问题 While porting an application from Linux x86 to iOS ARM (iPhone 4), I've discovered a difference in behavior on floating point arithmetics and small values. 64bits floating point numbers (double) smaller than [+/-]2.2250738585072014E-308 are called denormal/denormalized/subnormal numbers in the IEEE 754-1985/IEEE 754-2008 standards. On iPhone 4, such small numbers are treated as zero (0), while on x86, subnormal numbers can be used for computation. I wasn't able to find any explanation