decimal-point

Specifying decimal places on a variable in a string

好久不见. 提交于 2019-12-08 00:27:39
问题 after briefly looking for a few hours I see multiple solutions to my problem but I am struggling to implement them and hopefully someone can help a noob. The issue is that I have a drop down box in an ASP/MySQL web application that displays a few prices incorrectly. e.g if the data is 32.00 the figure displayed will be returned as 32, similarly if it 6.50 it displays as 6.5 The data type or the price is set to Decimal(19,2) length in the db table, and the price shows correctly elsewhere

Specifying decimal places on a variable in a string

心已入冬 提交于 2019-12-06 13:57:58
after briefly looking for a few hours I see multiple solutions to my problem but I am struggling to implement them and hopefully someone can help a noob. The issue is that I have a drop down box in an ASP/MySQL web application that displays a few prices incorrectly. e.g if the data is 32.00 the figure displayed will be returned as 32, similarly if it 6.50 it displays as 6.5 The data type or the price is set to Decimal(19,2) length in the db table, and the price shows correctly elsewhere except in this one instance of options displayed in a drop down box. I am pretty certain there is an easy

In Perl, how can I limit the number of places after the decimal point but have no trailing zeroes?

北城以北 提交于 2019-12-06 02:25:53
问题 This question is similar to "dropping trailing ‘.0’ from floats", but for Perl and with a maximum number of digits after the decimal. I'm looking for a way to convert numbers to string format, dropping any redundant '0', including not just right after the decimal. And still with a maximum number of digital, e.g. 3 The input data is floats. Desired output: 0 -> 0 0.1 -> 0.1 0.11 -> 0.11 0.111 -> 0.111 0.1111111 -> 0.111 回答1: You can also use Math::Round to do this: $ perl -MMath::Round=nearest

Replace dot(.) with comma(,) using RegEx?

时光怂恿深爱的人放手 提交于 2019-12-05 23:36:04
问题 I am working on a C# application. I want to change number decimal figure with comma(,) where i have dot(.) using regular expression. For example: Price= 100,00.56 As this international rule of representing numeric values but I Sweden they have different ways for numbers Like Price= 100.00,56 So i want to change dot(.) into comma(,) and comma(,) into dot(.) using RegEx. Could guide me about this. 回答1: When formatting numbers, you should use the string format overload that takes a CultureInfo

Truncating Double with VBA in excel

﹥>﹥吖頭↗ 提交于 2019-12-05 16:49:14
问题 I need to truncate the amount of decimal places of my double value for display in a textbox. How would one achieve this with vba? 回答1: You can either use ROUND for FORMAT in VBA For example to show 2 decimal places Dval = 1.56789 Debug.Print Round(dVal,2) Debug.Print Format(dVal,"0.00") Note : The above will give you 1.57 . So if you are looking for 1.56 then you can store the Dval in a string and then do this Dim strVal As String dVal = 1.56789 strVal = dVal If InStr(1, strVal, ".") Then

Determine the decimal precision of an input number

柔情痞子 提交于 2019-12-05 02:44:21
We have an interesting problem were we need to determine the decimal precision of a users input (textbox). Essentially we need to know the number of decimal places entered and then return a precision number, this is best illustrated with examples: 4500 entered will yield a result 1 4500.1 entered will yield a result 0.1 4500.00 entered will yield a result 0.01 4500.450 entered will yield a result 0.001 We are thinking to work with the string, finding the decimal separator and then calculating the result. Just wondering if there is an easier solution to this. Daniel Brückner I think you should

In Perl, how can I limit the number of places after the decimal point but have no trailing zeroes?

喜欢而已 提交于 2019-12-04 08:41:34
This question is similar to "dropping trailing ‘.0’ from floats" , but for Perl and with a maximum number of digits after the decimal. I'm looking for a way to convert numbers to string format, dropping any redundant '0', including not just right after the decimal. And still with a maximum number of digital, e.g. 3 The input data is floats. Desired output: 0 -> 0 0.1 -> 0.1 0.11 -> 0.11 0.111 -> 0.111 0.1111111 -> 0.111 You can also use Math::Round to do this: $ perl -MMath::Round=nearest -e 'print nearest(.001, 0.1), "\n"' 0.1 $ perl -MMath::Round=nearest -e 'print nearest(.001, 0.11111), "\n

Replace dot(.) with comma(,) using RegEx?

旧巷老猫 提交于 2019-12-04 06:19:49
I am working on a C# application. I want to change number decimal figure with comma(,) where i have dot(.) using regular expression. For example: Price= 100,00.56 As this international rule of representing numeric values but I Sweden they have different ways for numbers Like Price= 100.00,56 So i want to change dot(.) into comma(,) and comma(,) into dot(.) using RegEx. Could guide me about this. When formatting numbers, you should use the string format overload that takes a CultureInfo object. The culture name for swedish is "sv-SE", as can be seen here . decimal value = -16325.62m; Console

In Java, why does the decimal separator follow the Locale's language, not its country, and, more importantly, how does one override it?

*爱你&永不变心* 提交于 2019-12-04 03:57:47
I'm working on an international project and have observed that, in Java, the choice of the decimal separator is based on the Locale's language, not its country. For example: DecimalFormat currencyFormatter = (DecimalFormat) NumberFormat.getInstance(new Locale("it","IT")); System.out.println(currencyFormatter.format(-123456.78)); currencyFormatter = (DecimalFormat) NumberFormat.getInstance(new Locale("en","IT")); System.out.println(currencyFormatter.format(-123456.78)); produces the following output: -123.456,78 -123,456.78 I would have expected it to follow the country, since if I'm in the

Sorting records from Oracle with multiple decimal points (.)

不羁岁月 提交于 2019-12-04 03:50:24
UPDATE: ORACLE VERSION 10G I have a list of records in Oracle as follows, these are actually sections of various books The records are generated in the below format [main topic].[sub topic].[first level section] ..... .[last level section] Sections -------- 1 7.1 6.2 7.1 7.4 6.8.3 6.8.2 10 1.1 7.6 6.1 11 8.3 8.5 1.1.2 6.4 6.6 8.4 1.1.6 6.8.1 7.7.1 7.5 7.3 I want to order this like as follows 1 1.1 1.1.2 1.1.6 6.2 6.4 6.5 6.6 6.7 6.8.1 6.8.2 6.8.3 7.2 7.3 7.4 7.5 7.6 7.7.1 7.7.2 8.3 8.4 8.5 10 But as the field is not a numeric datatype the sorting results in something like this 1 10 1.1 1.1.2 1