floating-point

Ruby float precision

半腔热情 提交于 2020-12-25 00:57:21
问题 As I understand it, Ruby (1.9.2) floats have a precision of 15 decimal digits. Therefore, I would expect rounding float x to 15 decimal places would equal x . For this calculation this isn't the case. x = (0.33 * 10) x == x.round(15) # => false Incidentally, rounding to 16 places returns true. Can you please explain this to me? 回答1: Part of the problem is that 0.33 does not have an exact representation in the underlying format, because it cannot be expressed by a series of 1 / 2 n terms. So,

Ruby float precision

天涯浪子 提交于 2020-12-25 00:57:05
问题 As I understand it, Ruby (1.9.2) floats have a precision of 15 decimal digits. Therefore, I would expect rounding float x to 15 decimal places would equal x . For this calculation this isn't the case. x = (0.33 * 10) x == x.round(15) # => false Incidentally, rounding to 16 places returns true. Can you please explain this to me? 回答1: Part of the problem is that 0.33 does not have an exact representation in the underlying format, because it cannot be expressed by a series of 1 / 2 n terms. So,

what's the purpose of using media registers that can hold 32 bytes [duplicate]

三世轮回 提交于 2020-12-13 04:55:33
问题 This question already has answers here : What is the difference between non-packed and packed instruction in the context of SIMD-operations? (2 answers) What is the benefit of SIMD on a superscalar out-of-order CPU? (1 answer) What are some rules of thumb for when SIMD would be faster? (SSE2, AVX) [closed] (1 answer) Why floating point registers are different than general purpose ones (1 answer) Is there any architecture that uses the same register space for scalar integer and floating point

Are there any commonly used floating point formats besides IEEE754?

℡╲_俬逩灬. 提交于 2020-12-13 04:10:46
问题 I am writing a marshaling layer to automatically convert values between different domains. When it comes to floating point values this potentially means converting values from one floating point format to another. However, it seems that almost every modern system is using IEEE754, so I'm wondering whether it's actually worth generalising to allow other formats, or just manage marshaling between different IEEE754 formats. Does anyone know of any commonly used floating point formats other than

Are there any commonly used floating point formats besides IEEE754?

两盒软妹~` 提交于 2020-12-13 04:09:39
问题 I am writing a marshaling layer to automatically convert values between different domains. When it comes to floating point values this potentially means converting values from one floating point format to another. However, it seems that almost every modern system is using IEEE754, so I'm wondering whether it's actually worth generalising to allow other formats, or just manage marshaling between different IEEE754 formats. Does anyone know of any commonly used floating point formats other than

Are there any commonly used floating point formats besides IEEE754?

吃可爱长大的小学妹 提交于 2020-12-13 04:09:06
问题 I am writing a marshaling layer to automatically convert values between different domains. When it comes to floating point values this potentially means converting values from one floating point format to another. However, it seems that almost every modern system is using IEEE754, so I'm wondering whether it's actually worth generalising to allow other formats, or just manage marshaling between different IEEE754 formats. Does anyone know of any commonly used floating point formats other than

Are there any commonly used floating point formats besides IEEE754?

 ̄綄美尐妖づ 提交于 2020-12-13 04:08:00
问题 I am writing a marshaling layer to automatically convert values between different domains. When it comes to floating point values this potentially means converting values from one floating point format to another. However, it seems that almost every modern system is using IEEE754, so I'm wondering whether it's actually worth generalising to allow other formats, or just manage marshaling between different IEEE754 formats. Does anyone know of any commonly used floating point formats other than

implementing a hash table-like data structure with floating point keys where values within a tolerance are binned together

别来无恙 提交于 2020-12-12 06:50:40
问题 I need an associative data structure with floating point keys in which keys with nearly equal values are binned together. I'm working in C++ but language doesnt really matter. Basically my current strategy is to only handle single precision floating point numbers use an unordered_map with a custom key type define the hash function on the key type as a. given float v divide v by some tolerance, such as 0.0005, at double precision, yielding k . b. cast k to a 64 bit integer yielding ki c.

implementing a hash table-like data structure with floating point keys where values within a tolerance are binned together

蓝咒 提交于 2020-12-12 06:49:28
问题 I need an associative data structure with floating point keys in which keys with nearly equal values are binned together. I'm working in C++ but language doesnt really matter. Basically my current strategy is to only handle single precision floating point numbers use an unordered_map with a custom key type define the hash function on the key type as a. given float v divide v by some tolerance, such as 0.0005, at double precision, yielding k . b. cast k to a 64 bit integer yielding ki c.

How to compute the digits of an irrational number one by one?

£可爱£侵袭症+ 提交于 2020-12-06 16:56:43
问题 I want to read digit by digit the decimals of the sqrt of 5 in C. The square root of 5 is 2,23606797749979..., so this'd be the expected output: 2 3 6 0 6 7 9 7 7 ... I've found the following code: #include<stdio.h> void main() { int number; float temp, sqrt; printf("Provide the number: \n"); scanf("%d", &number); // store the half of the given number e.g from 256 => 128 sqrt = number / 2; temp = 0; // Iterate until sqrt is different of temp, that is updated on the loop while(sqrt != temp){ /