decimal

Parse csv to decimal on different cultures using CsvHelper in c#

时光毁灭记忆、已成空白 提交于 2021-01-28 14:23:42
问题 Problem with parsing decimals by CsvHelper in c#. I created a class that get csv file from byte[] istead of file, and it works correctly. public static List<Topic> GetAll(byte[] attachmentBytes) { using (Stream stream = new MemoryStream(attachmentBytes)) { using (var reader = new StreamReader(stream, Encoding.GetEncoding(1252), true)) { using (var csv = new CsvReader(reader)) { csv.Configuration.Delimiter = ";"; csv.Configuration.HasHeaderRecord = true; csv.Configuration.CultureInfo =

Accuracy of decimal

假如想象 提交于 2021-01-28 14:14:37
问题 I use the decimal type for high precise calculation (monetary). But I came across this simple division today: 1 / (1 / 37) which should result in 37 again http://www.wolframalpha.com/input/?i=1%2F+%281%2F37%29 But C# gives me: 37.000000000000000000000000037M I tried both these: 1m/(1m/37m); and Decimal.Divide(1, Decimal.Divide(1, 37)) but both yield the same results. How is the behaviour explainable? 回答1: Decimal stores the value as decimal floating point with only limited precision. The

Printing decimal number in assembly language?

本秂侑毒 提交于 2021-01-28 10:27:36
问题 I'm trying to get output in decimal form. Please tell me what I can do to get the same variable in decimal instead of ASCII. .model small .stack 100h .data msg_1 db 'Number Is = $' var_1 db 12 .code add_1 proc mov ax, @data mov ds, ax mov ah, 09 lea dx, msg_1 int 21h mov ah, 02 mov dl, var_1 int 21h mov ah, 4ch int 21h add_1 endp end add_1 回答1: These 3 lines that you wrote: mov ah, 02 mov dl, var_1 int 21h print the character represented by the ASCII code held in your var_1 variable. To print

Printing decimal number in assembly language?

房东的猫 提交于 2021-01-28 10:24:34
问题 I'm trying to get output in decimal form. Please tell me what I can do to get the same variable in decimal instead of ASCII. .model small .stack 100h .data msg_1 db 'Number Is = $' var_1 db 12 .code add_1 proc mov ax, @data mov ds, ax mov ah, 09 lea dx, msg_1 int 21h mov ah, 02 mov dl, var_1 int 21h mov ah, 4ch int 21h add_1 endp end add_1 回答1: These 3 lines that you wrote: mov ah, 02 mov dl, var_1 int 21h print the character represented by the ASCII code held in your var_1 variable. To print

Converting string to double with dot [duplicate]

旧街凉风 提交于 2021-01-28 03:40:46
问题 This question already has answers here : How do I print a double value without scientific notation using Java? (15 answers) Closed 4 years ago . I need to convert string value to double with dot. Here is simple code double dValue=Double.parseDouble("999999999.99"); System.out.println(dValue); output is: 9.9999999999E8 When i gave value like 10000 or 100000 it works. Help me to overcome this problem. 回答1: You could use BigDecimal and toPlainString() for that. BigDecimal dValue= new BigDecimal(

Python 'float64' cannot be converted to a MySQL type but in manual query thats no problem

て烟熏妆下的殇ゞ 提交于 2021-01-28 02:29:00
问题 I have python script and want insert data to database like this: (1, -0.12301105260848999) (1, 0.07728659361600876) (1, 0.005048183258622885) (1, -0.03252531960606575) (1, -0.05449267476797104) (1, -0.026811596006155014) (1, 0.014027083292603493) (1, -0.10952591896057129) (1, 0.15669232606887817) (1, -0.04698480665683746) (1, 0.26182907819747925) (1, -0.015784427523612976) And my table its ok, In that pict I try to manual insert data to db, and it's work fine. But in my python script return

Converting string to double with dot [duplicate]

好久不见. 提交于 2021-01-28 02:13:29
问题 This question already has answers here : How do I print a double value without scientific notation using Java? (15 answers) Closed 4 years ago . I need to convert string value to double with dot. Here is simple code double dValue=Double.parseDouble("999999999.99"); System.out.println(dValue); output is: 9.9999999999E8 When i gave value like 10000 or 100000 it works. Help me to overcome this problem. 回答1: You could use BigDecimal and toPlainString() for that. BigDecimal dValue= new BigDecimal(

Convert hex strings to integers

人盡茶涼 提交于 2021-01-28 00:33:59
问题 Visual Basic 2010: Recently in one of my projects I have been tasked with reading several data fields in hex. Each field is three characters long. So this is what I have been doing: 'Read the hex value and convert it to decimal Dim hexVal as string = "38D" Dim intVal as integer = Convert.ToInt32(hexVal, 16) 'The integer result gets multiplied by a scaling factor '(this is set by the manufacturer for each field). Dim fac as single = 200 Dim final as single = intVal * fac Debug.Print (final)

Decimal number in MSSQL table gets rounded although precision is set

橙三吉。 提交于 2021-01-27 14:30:20
问题 My c# object has a decimal property: public decimal LastPrice { get; set; } While processing my object, the decimal value gets set. For example: LastPrice = 0.091354; I modified my DbContext to increase the decimal precision as explained in another stackoverflow post: protected override void OnModelCreating(ModelBuilder modelBuilder) { foreach (var property in modelBuilder.Model.GetEntityTypes() .SelectMany(t => t.GetProperties()) .Where(p => p.ClrType == typeof(decimal) || p.ClrType ==

What is the correct type in c\c++ to store a COM's VT_DECIMAL?

荒凉一梦 提交于 2021-01-27 06:45:38
问题 I'm trying to write a wrapper to ADO. A DECIMAL is one type a COM VARIANT can be, when the VARIANT type is VT_DECIMAL . I'm trying to put it in c native data type, and keep the variable value. it seem that the correct type is long double, but I get "no suitable conversion error". For example: _variant_t v; ... if(v.vt == VT_DECIMAL) { double d = (double)v; //this works but I'm afraid can be loss of data... long double ld1 = (long double)v; //error: more then one conversion from variant to