decimal

VBA changing decimal to comma automaticaly

荒凉一梦 提交于 2019-12-05 22:19:34
I have an Excel Macro in VBA. Yesterday everything worked fine, this morning VBA is taking a decimal point and changing the point to a comma. That is from 5.1 to 5,1. I am using a German system and have set in Excels advanced options that a point is a decimal and comma is thousands. For example I have a value for daily scrum meeting in the Excel sheet set at 3.75 Excel sheet input: when I use a function to read in the value such as: Sub TestFunction() MsgBox (Sheets("Input_Parameters").Cells(25, 2)) End Sub I get the value with commas. VBA function output: Is there a setting in the VBA

ATM style decimal places

时光总嘲笑我的痴心妄想 提交于 2019-12-05 20:55:02
I'm working on getting an old piece of code working, from 2003. I'm trying to replicate an ATM style decimal textbox. This code claims to have worked for someone, but I am having trouble implementing it. Maybe someone has a better way of achieving this? Maybe in jQuery? This is how I would solve it: http://jsfiddle.net/77bMx/86/ Handles numpad input as well as standard number keys Works with backspace Will revert to 0.00 if you somehow manage to produce illegal input (like backspacing too much) The basic idea is to intercept any input to the box, make sure it's of the correct type (a number,

How to convert a string containing an exponential number to decimal and back to string

左心房为你撑大大i 提交于 2019-12-05 20:49:28
I'm converting code between delphi and c#. Values are stored as strings in a text file from the delphi app. An example of the stored value is : '4.42615029219009E-5' Now in my c# app I need to read in that string value and then later have the capability to write out the value again. Initially I used code similar to: string stringField = "4.42615029219009E-5"; double someMoneyVar = Convert.ToDouble(stringField) later if I need to recreate the text file with the value of someMoneyVar then using a simple: string.Format("{0}", someMoneyVar) would output: 4.42615029219009E-05 // note the 0 Lastly,

Can't edit decimal type value in locals window VS2015

▼魔方 西西 提交于 2019-12-05 20:37:23
Example C# code (in form load event): int a = 5; double b = 7.2; decimal c = 9.99m; string d = "test"; MessageBox.Show(a.ToString() + "\n" + b.ToString() + "\n" + c.ToString() + "\n" + d); Put a breakpoint on the messagebox line and run. Try to edit the values a, b, c and d in a locals window (or autos or watch). The integer, double and string values can be changed, but the decimal value (c) keeps changing back to the original (9.99m). Why is this? Possible bug? Or am I not getting something? This issue was resolved in Visual Studio 2015 Update 2, released March 30, 2016. 来源: https:/

python decimals - rounding to nearest whole dollar (no cents) - with ROUND_HALF_UP

◇◆丶佛笑我妖孽 提交于 2019-12-05 20:27:50
I'm trying to use Decimal.quantize() to achieve the following: - For any amount of money, expressed as a python decimal of default precision, I want to round it using decimal.ROUND_HALF_UP so that it has no cents after rounding. For example, given 1.25, I'm trying to obtain 1.00 (signifying no cents) given 1.49 I'm trying to obtain 1.00 given 1.50 I'm trying to obtain 2.00 given 1.87 I'm trying to obtain 2.00 given 2.00 I'm trying to obtain 2.00 So there are two ranges for the cents -- 0 cent to 49 cents; and 50 cents to 99 cents. For cents upto 49, I want to round down, for cents 50 and up I

Use comma for decimals and period for thousands rdlc report

让人想犯罪 __ 提交于 2019-12-05 18:57:40
I'm using Report Viewer Control (rdlc) to generate reports. One of my columns represent a decimal value from a SQL database, for example: 5199.9800 and at the end of this column, all the amounts are summed. So, the amounts rows are represented this way: =Fields!DEBIT.Value And the total row is represented this way: =Sum(CDbl(Fields!DEBIT.Value), "dtsItems") Currently all the values are formatted in the standard way, using comma for thousands and period for decimals like this: 5,199.98 but i need to format it the opposite way: using period for thousands and comma for decimals, like this: 5.199

mvc4 - db.SaveChanges() - decimal value out of range

社会主义新天地 提交于 2019-12-05 18:46:49
I'm building an MVC4 application that requires me to generate a 21 digit key when 'creating' a new record. Here is my context where i'm defining the db columns: public class cust { public int ID { get; set; } public decimal CPCUST_KEY { get; set; } public decimal CPCUST_TOKEN { get; set; } public decimal CPCUST_ALTERNATE_KEY { get; set; } In my SQL Server table the items are all set as 'decimal(38, 0)'...I believe I should be using a decimal data type? Somehow i'm still getting the out of range error below. My number is well within the 38 digit max length of my SQL variable. System.Data.Entity

Python decimal.Decimal precision doesn't match wolfram alpha's

▼魔方 西西 提交于 2019-12-05 18:32:48
I have the following python code: In [1]: import decimal In [2]: decimal.getcontext().prec = 80 In [3]: (1-decimal.Decimal('0.002'))**5 Out[3]: Decimal('0.990039920079968') Shouldn't it match 0.99003992007996799440405766290496103465557098388671875 according to this http://www.wolframalpha.com/input/?i=SetPrecision%5B%281+-+0.002%29%5E5%2C+80%5D ? Wolfram alpha is actually wrong here. (1 - 0.002) ** 5 is exactly 0.990039920079968 . You can verify that by simply assessing that there are 15 digits after the . , which matches 5 * 3 , 3 being the number of digits after the . in the expression (1 -

Overflow Exception when dividing two decimals in .NET

Deadly 提交于 2019-12-05 15:34:49
I'm having an issue trying to divide two decimals and then display the result. Annoyingly this is only happening on our server, and it appears to work perfectly fine if I run the code locally. This is the code that I am trying to run decimal dOne = -966.96M; decimal dTwo = 2300M; decimal dResult = Decimal.Round((dOne / dTwo), 28, MidpointRounding.AwayFromZero); The resulting number (as generated from windows calculator) is -0.43346086956521739130434782608696 This always results in an overflow exception: System.OverflowException: Value was either too large or too small for a Decimal. at System

Decimal order of addition affects results

主宰稳场 提交于 2019-12-05 11:45:34
I have a system that is performing lots of calculations using decimals, occasionally it will add up the same numbers, but return different results, +/- 0.000000000000000000000000001 Here is a short example: decimal a = 2.016879990455473621256359079m; decimal b = 0.8401819425625631128956517177m; decimal c = 0.4507062854741283043456903406m; decimal d = 6.7922317815078349615022988627m; decimal result1 = a + b + c + d; decimal result2 = a + d + c + b; Console.WriteLine((result1 == result2) ? "Same" : "DIFFERENT"); Console.WriteLine(result1); Console.WriteLine(result2); That outputs: DIFFERENT 10