double

Algorithm to generate all permutations of pairs without repetition

倖福魔咒の 提交于 2020-06-13 07:16:34
问题 Although there are numerous articles about generating permutations, I have an algorithmic need for permutation that's just a bit different. Given a set of elements (a, b, c, .. n) I construct pairs: (ab), (cd), (ef), ... in any combination of elements. Pairs (ab) and (ba) are identical. Also the needed permutations should not be different only in sequence: (ab), (ef), (cd) is identical to (ef), (cd), (ab) As an example, I'll show the exhaustive list of permutations for 6 elements a, b, c, d,

How to see the size of the incoming floating point number?

本秂侑毒 提交于 2020-06-01 07:36:28
问题 The user writes a number to the input, it is stored in a string. How can I check if this number is included in size in the float type or does it need a double ? 回答1: Unless your floating point numbers are huge or extremely small, i.e. out of the range spanning -3.4E38 to 3.4E38, a float 32 will store anything you throw at it in terms of size but not accuracy. As such, the real issue is how many significant digits you need in order to minimize rounding errors. I recommend you to read https:/

Why is a float “single precision”?

巧了我就是萌 提交于 2020-05-25 06:53:05
问题 I'm curious as to why the IEEE calls a 32 bit floating point number single precision. Was it just a means of standardization, or does 'single' actually refer to a single 'something'. Is it simply a standardized level? As in, precision level 1 (single), precision level 2 (double) and so on? I've searched all over and found a great deal about the history of floating point numbers, but nothing that quite answers my question. 回答1: On the machine I was working on at the time, a float occupied a

Why is a float “single precision”?

China☆狼群 提交于 2020-05-25 06:51:37
问题 I'm curious as to why the IEEE calls a 32 bit floating point number single precision. Was it just a means of standardization, or does 'single' actually refer to a single 'something'. Is it simply a standardized level? As in, precision level 1 (single), precision level 2 (double) and so on? I've searched all over and found a great deal about the history of floating point numbers, but nothing that quite answers my question. 回答1: On the machine I was working on at the time, a float occupied a

Sum up ArrayList<Double> via Java Stream [duplicate]

蹲街弑〆低调 提交于 2020-05-25 06:09:00
问题 This question already has answers here : Is mapToDouble() really necessary for summing a List<Double> with Java 8 streams? (3 answers) Closed 4 years ago . Im trying to Figure out how to Sum up all the elements of an 'ArrayList'. Ive tried already: double totalevent = myList.stream().mapToDouble(f -> f).sum(); while myList is a ArrayList<Double> . is there a way to do it without the useless mapToDouble function? 回答1: The mapToDouble call is not useless: it performs an implicit unboxing.

Sum up ArrayList<Double> via Java Stream [duplicate]

社会主义新天地 提交于 2020-05-25 06:05:02
问题 This question already has answers here : Is mapToDouble() really necessary for summing a List<Double> with Java 8 streams? (3 answers) Closed 4 years ago . Im trying to Figure out how to Sum up all the elements of an 'ArrayList'. Ive tried already: double totalevent = myList.stream().mapToDouble(f -> f).sum(); while myList is a ArrayList<Double> . is there a way to do it without the useless mapToDouble function? 回答1: The mapToDouble call is not useless: it performs an implicit unboxing.

how to printf long double in C? [duplicate]

﹥>﹥吖頭↗ 提交于 2020-05-23 13:16:29
问题 This question already has answers here : printf and long double (8 answers) Closed 5 years ago . [Update] The results would still be the same no matter I use lf , Lf , llf ...I am using Code Blocks to compile and run my C program. I am using GNU GCC compiler. I tried to printf long double float type on different computers including two Windows and one Mac but it turns out that none of them is working as I expected. The code is the following: #include <stdio.h> #include <stdlib.h> int main() {

Can “System.Math.Cos” return a (float)?

本秂侑毒 提交于 2020-05-23 08:00:24
问题 In C# it bugs me how there is no "Math.Cos" function that returns a float. A double is the only value you can get back thus forcing you to cast it to a float. Like so: float val = (float)Math.Cos(someVal); I need to use floats because i'm doing stuff in Direct3D which strictly uses floats. Floats are much more common in the graphics world(as it stands now) because they are 32bit. Is there any functionality within C# I can use that would simply just process floats like C++ can do?? I do not

Can “System.Math.Cos” return a (float)?

泄露秘密 提交于 2020-05-23 08:00:13
问题 In C# it bugs me how there is no "Math.Cos" function that returns a float. A double is the only value you can get back thus forcing you to cast it to a float. Like so: float val = (float)Math.Cos(someVal); I need to use floats because i'm doing stuff in Direct3D which strictly uses floats. Floats are much more common in the graphics world(as it stands now) because they are 32bit. Is there any functionality within C# I can use that would simply just process floats like C++ can do?? I do not

Java output double numbers in exponential format

半世苍凉 提交于 2020-05-13 06:11:25
问题 I have some double numbers that are outputted with this format: Format.String("%1.4e",doubleNumber); The result is 1.123456e+03 . How can I set the number of cipher of exponent for getting this format: 1.123456e+003 I would have always 3 cipher after e symbol. Thank you UPDATE 1: I have partially resolved: DecimalFormat formatter = new DecimalFormat("0.000000E000"); System.out.println( formatter.format(doubleNumber) ); Now the number has always the format 1.123456e0xx or 1.123456e-0xx But it