decimal

Regex in PreviewTextInput: only decimals between 0.0 and 1.0

好久不见. 提交于 2020-02-08 09:26:25
问题 I'd like to have a regex, which only allows digits between 0.0 and 1.0 in a textbox. BUT it should be in the method PreviewTextInput (C#, WPF project) So the normal regex doesn't work Regex regex = new Regex(@"^0|0.0|0\.[0-9]*|1\.0|1$"); I've found a regex, which allows all decimals in the PreviewTextInput method: Regex regex = new Regex("^[.][0-9]+$|^[0-1.]*[.,]{0,1}[0-9]*$"); How can a change this regex to only accept decimals between 0-1? Thanks. My method for decimals: private void tb

Decimal input edittext in java

有些话、适合烂在心里 提交于 2020-02-06 08:43:26
问题 I want to have an edit text with some value like 0.00 and cursor must be on the left side. when user press 1 it should be 1.00, when user presses 2 it should be 12.00, when user press "." cursor should move to the other side of decimal. After shifting to the other side of decimal when user press 3 it should be 12.30 and on pressing 4 it should be 12.34. Similarly on backpress it should be 12.30 -> 12.00 -> 1.00 -> 0.00.sample import android.text.Editable; import android.text.TextWatcher;

How does the caller know when there's a Decimal inside a VARIANT?

岁酱吖の 提交于 2020-02-04 01:18:05
问题 The COM VARIANT type is defined using the tagVARIANT structure like this: typedef struct tagVARIANT { union { struct { VARTYPE vt; WORD wReserved1; WORD wReserved2; WORD wReserved3; union { LONGLONG llVal; LONG lVal; BYTE bVal; SHORT iVal; FLOAT fltVal; DOUBLE dblVal; VARIANT_BOOL boolVal; VARIANT_BOOL __OBSOLETE__VARIANT_BOOL; SCODE scode; CY cyVal; DATE date; BSTR bstrVal; IUnknown *punkVal; IDispatch *pdispVal; SAFEARRAY *parray; BYTE *pbVal; SHORT *piVal; LONG *plVal; LONGLONG *pllVal;

Javascript : Rounding 2 decimal places of boundary 0.5

China☆狼群 提交于 2020-01-30 12:03:42
问题 How to get the rounding number of 0.5, previously I found in this link: Click here But this is not what I want: I want like this example: 10.24 = 10.25 17.90 = 17.90 3.89 = 3.90 7.63 = 7.65 jQuery will be fine with me. 回答1: Use Math.round(num * 20) / 20 , if you are looking to round a number to nearest 0.05 . 回答2: This will do what you need... function roundoff(value) { return (Math.round(value / 0.05) * 0.05).toFixed(2); } Using Math.round will round the value to the nearest 0.05, and then

Counting number of digits of input using python

点点圈 提交于 2020-01-30 05:57:25
问题 I am trying to count the number of digits of an input. However, whenever I input 10 or 11 or any two digit number, the output is 325 . Why doesn't it work? inputnumber = int(input()) countnumber = inputnumber digitcount = 0 while countnumber > 0: digitcount += 1 countnumber = countnumber/10 print(digitcount) # result is 325 when input is 10 or 11 回答1: Your error mainly happened here: countnumber=countnumber/10 Note that you are intending to do integer division. Single-slash division in Python

How to get largest possible precision? (Python - Decimal)

自作多情 提交于 2020-01-30 04:19:10
问题 I'm using the Decimal class for operations that requires precision. I would like to use 'largest possible' precision. With this, I mean as precise as the system on which the program runs can handle. To set a certain precision it's simple: import decimal decimal.getcontext().prec = 123 #123 decimal precision I tried to figure out the maximum precision the 'Decimal' class can compute: print(decimal.MAX_PREC) >> 999999999999999999 So I tried to set the precision to the maximum precision (knowing

C# unlimited significant decimal digits (arbitrary precision) without java [duplicate]

霸气de小男生 提交于 2020-01-27 08:46:16
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: what is the equivalent for java class : BigDecimal in c# I know in this post: Arbitrary precision decimals in C#? says to use java.math.BigDecimal, but I don't have J# installed. How would I achieve arbitrary precision in C#? I was thinking of using binary strings but I may run into some trouble when multiplying the two. 回答1: See What is the equivalent of the Java BigDecimal class in C#? You could create your

C# unlimited significant decimal digits (arbitrary precision) without java [duplicate]

≡放荡痞女 提交于 2020-01-27 08:42:10
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: what is the equivalent for java class : BigDecimal in c# I know in this post: Arbitrary precision decimals in C#? says to use java.math.BigDecimal, but I don't have J# installed. How would I achieve arbitrary precision in C#? I was thinking of using binary strings but I may run into some trouble when multiplying the two. 回答1: See What is the equivalent of the Java BigDecimal class in C#? You could create your

Converting Binary to Decimal in Java [duplicate]

佐手、 提交于 2020-01-26 04:17:12
问题 This question already has answers here : Converting Decimal to Binary Java (28 answers) Closed 6 years ago . I'm almost done with implementing a code that allows the user to input a decimal number into binary and then have the binary number reversed and then converted back to decimal. I solved everything except for the Binary to decimal part. It keeps giving me the same number over and over again no matter what I type. I don't understand why. Basically, why is the last part of my code wrong?

convert time to decimal in SQL server 2012

女生的网名这么多〃 提交于 2020-01-25 14:38:31
问题 i have a table in sql server 2012, with one of its column having the following data in time datatype, How would you convert 00:45:00 to 0.45 or 01:45:00 to 1.45 ? please help. 回答1: From the question, it seems you only want to remove the ':' with '.'. If so, it can be achieved in many ways in sql server 2012. One example is below. If your column is 'Datetime', use this: SELECT REPLACE(LEFT(CAST(DatetimeCol AS TIME),5),':',',') FROM Tbl Else if it just 'Time' then remove the casting. 回答2: You