double

Binary operations on doubles in C

情到浓时终转凉″ 提交于 2019-12-12 06:41:05
问题 I'm working on a high speed computing problem for a large scale simulation. In order to speed up the process I wish to make a couple of optimizations, one of which is to compute the absolute value of a double in only a couple of cycles without jumps. My idea was, that 64-Bit double values are represented with a 1-Bit sign Bit, an 11-Bit exponent and a 52-Bit Mantissa. So a double value XOR-ed with a mask: 10000000 00000000 00000000 00000000 would yield the desired result: double abs(double x)

Rounding the SIGNIFICANT digits in a double, not to decimal places [duplicate]

无人久伴 提交于 2019-12-12 06:20:13
问题 This question already has answers here : Round a double to x significant figures (13 answers) Closed 4 years ago . I need to round significant digits of doubles. Example Round(1.2E-20, 0) should become 1.0E-20 I cannot use Math.Round(1.2E-20, 0), which returns 0, because Math.Round() doesn't round significant digits in a float, but to decimal digits, i.e. doubles where E is 0. Of course, I could do something like this: double d = 1.29E-20; d *= 1E+20; d = Math.Round(d, 1); d /= 1E+20; Which

Double to string Java Loop

时光毁灭记忆、已成空白 提交于 2019-12-12 06:08:51
问题 Hey so I am trying to get the GC-content of a DNA string is given by the percentage of symbols in the string that are C or G. For example, the GC-content of "AGCTATAG" is .375 or 37.5%. Here is what I came with up. I am having trouble with the calculations and returning the double as string. public static double gcContent(String dna) { //TODO Implement this method double gcContent = 0; double count=0; for (int i = 0; i < dna.length(); i ++) { if (gcContent == dna.length()){ gcContent = (dna

Fetching a result twice with deferend name

怎甘沉沦 提交于 2019-12-12 05:25:02
问题 I have 1 table with tasks named opentask: columns: id,title,description,expires,creator_id,creator_name, executer_id, executer_name, priority_id, status_id 1 table with users named user: with columns: user_id, username What I want is to create a query where there will be all columns from opentask table where the executer_id will be equal to the user_id of user table AND the creator_id will be equal to the user_id again. This creates a confusion because the first equality excludes the second.

Can double be used to store and safely retrieve 128 bit IPv6?

こ雲淡風輕ζ 提交于 2019-12-12 05:04:44
问题 As we know double can store number from ±4.94065645841246544e-324 to ±1.79769313486231570e+308 . Can we store 128 bits value like IPv6 in double and retrieve as it is? For example, to store IPv4 we can use a 32 bit integer and store them as 8 bits partition. And we can retrieve them by using bit masking. There is no standard container to store 128 bit in any language AFAIK. I know double can store 64 bits safely without any precision error but is there any hack? 回答1: Technically you could, if

Using double in Core Data

走远了吗. 提交于 2019-12-12 05:02:41
问题 I'm very new to iOS and swift 2 and I am making an app which would require a double value for the attribute of an entity in core data. There are many tutorials with strings as attributes but no double. Can you please help me by showing an example of how double attribute can be created using core data .I want to store the value in a table view controller. Thanks in advance 来源: https://stackoverflow.com/questions/37958530/using-double-in-core-data

Handling doubles with large integer parts in C++

冷暖自知 提交于 2019-12-12 04:56:27
问题 I need to handle sub-metre coordinates in C++ which have large integer parts (e.g. 515876.12 // 5117789.22), but I'm having issues with rounding: double inUTMX = 560351.12 is displayed as 560351 double inUTMY = 5113570.22 is displayed as 5.11357e+06 I can normalise the coordinates for processing if necessary (e.g. /1e5), but I need to read-in the sub-metre coordinates via command line in the first place. Trouble is they always get rounded. Is there a neat way to deal with doubles that have

How do I parse a string representing a sequence of arithmetic operations?

℡╲_俬逩灬. 提交于 2019-12-12 04:55:35
问题 I am working on a personal project and I want to take in userinput that looks like this : 1.0+2.5+3--4 and format it to something like this : 1.0 + 2.5 + 3 - -4 so far I am using the .replace("+") to .replace(" + ") and doing that for all of the operands but the problem is it makes the user input into this: 1.0 + 2.5 + 3 - - 4 Is there a way that I can make it with the negative signs. I want to do this so I could parse the numbers into doubles and add and subtract them later on. my code for

How to read a 64-bit two's-complement integer from a binary file using R?

耗尽温柔 提交于 2019-12-12 04:55:09
问题 I gather that to represent a 64-bit integer in R I need to use a double. That's fine but I need to read such an integer from a binary file where it is stored as Big Endian 64-bit two's-complement (a java long). I can of course read the two signed integers in 4 byte chunks like so a = readBin(file, integer(), size=4, endian="big") b = readBin(file, integer(), size=4, endian="big") But how do I combine them in R to get the double I require? 回答1: It is definitely better to read it in as two

MySQL Finding min/max values for double

北慕城南 提交于 2019-12-12 04:46:24
问题 The relevant MySQL documentation states that for doubles: Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308. and These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system. I'm finding that the actual range is actually smaller on my system! Is there a SQL query or some other way to find out what the actual minimum and