double

Get value double value from string using RegEx in vb.net

丶灬走出姿态 提交于 2019-12-13 06:13:13
问题 I have following string value which is coming from database. str= ">= 5.0 years" Now from this string i want the value of double number (5.0). How can i get this value from this string? Can any one tell me how to get the value like 5.0 from above string? Thanks in advance. 回答1: Try using this pattern: PATTERN \d+?.\d+ I'm not sure how to use regex in Visual Basic, however this C# code should help you: C# code string regex = @"\d+?.\d+"; string myString = ">= 5.0 years"; MatchCollection

iOS UIStepper & NSUserDefaults - How to manage them together and use a double

时间秒杀一切 提交于 2019-12-13 06:03:53
问题 I have the following code. However, the line stepper.value = [NSNumber numberWithDouble:loadNumber]; errors with the error 'Sending NSNumber *__strong to a parameter of incompatible type 'double''. I think the stepper will only accept a double, but am unsure what I am doing wrong to set it. What I need to achieve is the following:- 1) Have a default value set in NSUserDefaults for saveNumber , which will be used until a variation is made by the user. 2) on load or view appearing, use

Can floating-point data types be used to store exact numbers at all?

萝らか妹 提交于 2019-12-13 05:18:33
问题 If I directly (not getting it as a result of a calculation), explicitly assign 0.0001 to a variable of a Double type, is it guaranteed to be exactly equal to 0.0001 wherever it goes? 回答1: No... because it's simply impossible to represent 0.0001 as a (finite) binary fraction - you'll get a rounding error when the literal is compiled or interpreted. However, integer numbers can be stored without rounding - up to the limit of precision, which is of course lower than for an integer type of the

Java: Why the Hex value is different for same floating-point value?

只愿长相守 提交于 2019-12-13 04:53:15
问题 So I have BigDecimal holding value 0.99 and I invoke: Float.toHexString(rationalNumber.floatValue()) I get 0x1.fae148p-1 Double.toHexString(rationalNumber.doubleValue()) I get 0x1.fae147ae147aep-1 I'm thinking since we are representing a small number like 0.99 we should get the same hex value regardless. Agree? Code (failing test): @Test public void testDelta() { BigDecimal rationalNumber = new BigDecimal("0.99").setScale(2,BigDecimal.ROUND_DOWN); String hexFromFloat = Float.toHexString

Double to int rounding normal way from .5 [duplicate]

故事扮演 提交于 2019-12-13 04:35:59
问题 This question already has answers here : Division of integers in Java [duplicate] (7 answers) Closed 5 years ago . I'm making calculation and for that I'm using the following expression: Player.targetx = (int) (((e.getX() - Frame.x)/(Screen.myWidth/World.worldWidth))-8); For example: if the values are (((103 - 40)/(1184/15))-8) the double answer is around -7.20186 . Player.targetx still gets value of -8 . Why's that? I would like to make it so that -7.5 gives me answer of -8 and anything like

Reading FORTRAN-written double precision variables in R

南楼画角 提交于 2019-12-13 04:31:24
问题 I have a file containing double precisions written from a FORTRAN code in the format of x.yyyyD+zz . When using read.csv in R, R does not seem to recognize those as floating point values. I'm new to R; what's the trick here? 回答1: Use sed or your favourite text editor to change the D s to E s, I expect R will happily read the numbers after you do that. 来源: https://stackoverflow.com/questions/29962999/reading-fortran-written-double-precision-variables-in-r

Recursive parameters for quicksort

﹥>﹥吖頭↗ 提交于 2019-12-13 04:29:48
问题 I'm trying to implement a simple Quicksort Algorithm (Doubly Linked List, circular). The Algorithm works pretty well, but it's much too slow, because of the following operation: iEl = getListElement(l); jEl = getListElement(r); On very long input-list I have to constantly go through the whole list, to find iEl and jEl , which is ultra-slow. The solution would be (I think), to pass those two Elements as Parameters to the partition Function. Problem is, I can't find the correct Elements for

Detecting if a string is a double or long in C

拜拜、爱过 提交于 2019-12-13 04:29:15
问题 I'm dealing with an char[] containing text which should represent a double number value OR a long number. I'm in a need to write a function that detects which of the above data-types is represented (if any). I thought about using strtol() and check if it fails to parse the entire string, and if it fails, using strtod(). I would be happy to see whether there is a better option to do so. Thanks. 回答1: I thought about using strtol() and check if it fails to parse the entire string, and if it

Java double equality

天大地大妈咪最大 提交于 2019-12-13 04:06:43
问题 I'm having a problem in comparing doubles. The comparison is responsible for stopping a while cycle. The code runs fine, but then suddenly, the cycle never stops. The values from centroidList's dimVal are being compared to the temp variable which is calculated(the bold bit). The code always enters the if, it doesn't matter if I use "!=" or "==". Printed out the values, they are exactly the same. What is wrong? package clusters; import java.util.LinkedList; public class KMeansV2 { LinkedList

Java DecimalFormat

蓝咒 提交于 2019-12-13 04:01:52
问题 DecimalFormat df2 = new DecimalFormat("#.##"); double zipf = 0.23951367781155017; String zipt = df2.format(zipf); System.out.println(zipt); And I get "0,24" The problem with this is then I want to use it as a double. But the Double.valueOf(); method fails due to the comma being there in the string output. Any way to solve this? 回答1: For decimal dot, you should create an instance with english locale like this: NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH); nf