double

Convert Delphi Real48 to C# double

我怕爱的太早我们不能终老 提交于 2019-12-21 04:32:16
问题 I need to be able to convert from a Delphi Real48 to C# double. I've got the bytes I need to convert but am looking for an elegant solution. to the problem. Anybody out there had to do this before? I'm needing to do the conversion in C# Thanks in advance 回答1: I've done some hunting around and I found some C++ code to do the job, converted it and it seems to be giving the right answer... damned if I understand it all though :S private static double Real48ToDouble(byte[] real48) { if (real48[0]

C++ casting static two-dimensional double array to double**

纵然是瞬间 提交于 2019-12-21 04:21:02
问题 I have such matrix in my program: double m[3][4] = { {2, 4, 5, 7}, {4, 5, 1, 12}, {9, 12, 13, -4} }; And I'd like to cast it to double** type. I've already tried simple double** a = (double**)m; , but it doesn't work (when I try to read any value, I get "Access violation reading location 0x00000000.", which means I'm trying to read from NULL adress. I found almost working solution: double *b = &m[0][0]; double **c = &b; It works when I read field c[0][any] But same NULL adress reading problem

How to get the numbers after the decimal point? (java) [duplicate]

青春壹個敷衍的年華 提交于 2019-12-21 03:15:05
问题 This question already has answers here : How do I get whole and fractional parts from double in JSP/Java? (17 answers) Closed 6 years ago . double d = 4.321562; Is there an easy way to extract the 0.321562 on it's own from d? I tried looking in the math class but no luck. If this can be done without converting to string or casting to anything else, even better. 回答1: Well, you can use: double x = d - Math.floor(d); Note that due to the way that binary floating point works, that won't give you

What's the point of float_t and when should it be used?

拜拜、爱过 提交于 2019-12-20 18:31:47
问题 I'm working with a client who is using an old version of GCC (3.2.3 to be precise) but wants to upgrade and one reason that's been given as stumbling block to upgrading to a newer version is differences in the size of type float_t which, sure enough is correct: On GCC 3.2.3 sizeof(float_t) = 12 sizeof(float) = 4 sizeof(double_t) = 12 sizeof(double) = 8 On GCC 4.1.2 sizeof(float_t) = 4 sizeof(float) = 4 sizeof(double_t) = 8 sizeof(double) = 8 but what's the reason for this difference? Why did

Comparing Double.NaN with itself

北慕城南 提交于 2019-12-20 16:10:55
问题 I am stuck trying to find out why these two operations return different values: Double.NaN == Double.NaN returns false Double.NaN.Equals(Double.NaN) returns true I have the answer to the first part but not the second and not to "why are these two comparisons returning different values" 回答1: The reason for the difference is simple, if not obvious. If you use the equality operator == , then you're using the IEEE test for equality. If you're using the Equals(object) method, then you have to

Java double.MAX_VALUE?

蹲街弑〆低调 提交于 2019-12-20 11:40:07
问题 For my assignment I have to create a Gas Meter System for a Gas company to allow employees to create new costumer accounts and amend data such as name and unit costs along with taking(depositing) money from their account. I have created my constructor and even added in a method of overloading although I'm currently running into a problem when initiating one of my methods I named deposit , this is supposed to take money from the users account while other methods such as recordUnits allows the

How to cast the size_t to double or int C++

匆匆过客 提交于 2019-12-20 10:29:32
问题 My question is that I have a size_t data, but now I want to convert it to double or int. If I do something like size_t data = 99999999; int convertdata = data; the compiler will report warning. because it maybe overflow. Do you have some method like the boost or some other method to do the convert? 回答1: A cast, as Blaz Bratanic suggested: size_t data = 99999999; int convertdata = static_cast<int>(data); is likely to silence the warning (though in principle a compiler can warn about anything

Java double vs BigDecimal for latitude/longitude

雨燕双飞 提交于 2019-12-20 08:59:13
问题 When storing latitudes/longitudes which are typically of the format: 44.087585 (i.e. max 2 numbers before the dot and 6dp) do I need to bother with bigdecimals? 回答1: Using double has enough precision for accurate lat/lon down to inches for 6-7 decimal places. In aviation, if decimal degrees are used, they typically go to at least 7 decimal places. In our NASA simulations, lat/lon data are doubles while all other attitude and altitude are floats. In other words, the 6th decimal place for

How to pick up only integer data from an ArrayList of String

夙愿已清 提交于 2019-12-20 07:48:45
问题 I read a text file and put the data into an ArrayList of String . The data is like China 12351235123 Korea 123532523 USA 12341235123 I just need those integer data as an integer to find the first digit of the integers. I know how to find the first digit, but I don't know how I can pick up only the integer data. 回答1: I am assuming that your ArrayList is of type String . replaceAll() will take out anything that isn't a number(0-9) ArrayList<String> countrys = new ArrayList<String>(); countrys

How to use Bitxor for Double Numbers?

末鹿安然 提交于 2019-12-20 07:44:34
问题 I want to use xor for my double numbers in matlab,but bitxor is only working for int numbers. Is there a function that could convert double to int in Matlab? 回答1: The functions You are looking for might be: int8(number) , int16(number) , uint32(number) Any of them will convert Double to an Integer, but You must pick the best one for the result You want to achieve. Remember that You cannot cast from Double to Integer without rounding the number. If I understood You correcly, You could create a