decimal

mySQL format number output , thousands separator

半腔热情 提交于 2019-12-08 00:57:40
问题 I have a mySQL query which is outputting decimal fields with a comma. SELECT Metals.Metal, FORMAT(Fixes.GBPam, 3) AS AM, FORMAT(Fixes.GBPpm, 3) AS PM, DATE_FORMAT(Fixes.DateTime, '%d-%m-%y') AS Date FROM Fixes, Metals WHERE Metals.Id = Fixes.Metals_Id Fields GBPam and GBPpm are both of type decimal(10,5) Now I want columns AM and PM to be formatted to 3 decimal places in my sql query - Correct I want values in the thousands to be formatted as xxxx.xxx and not x,xxx.xxx - Incorrect Example

How to represent floating point in binary. IEEE

眉间皱痕 提交于 2019-12-07 23:41:33
Similar to decimal binary numbers can have represent floats too. Now I read that it can have floats of the sort 0.5 : 0.1 , 0.25 : 0.01 , 0.125 : 0.001 ... and so on. But then, for example, how is the 0.1(in decimal) represented in binary? Also, given a decimal float, how to convert it to the decimal equivalent, (given it is not so straightforward). Edit: So I understand that the better question would have been ; how to convert a decimal float to binary? Now i get it that we multiply the decimal part, till it becomes zero. Now it is very much possible that two floating points can have the same

C++ convert decimal hours into hours, minutes, and seconds

走远了吗. 提交于 2019-12-07 22:47:58
问题 I have some number of miles and a speed in MPH that I have converted into the number of hours it takes to travel that distance at that speed. Now I need to convert this decimal number into hours, minutes, and seconds. How do I do this? My best guess right now is: double time = distance / speed; int hours = time; // double to integer conversion chops off decimal int minutes = (time - hours) * 60; int seconds = (((time - hours) * 60) - minutes) * 60; Is this right? Is there a better way to do

What's the second minimum value that a decimal can represent?

亡梦爱人 提交于 2019-12-07 18:43:37
问题 What's the second minimum value that a decimal can represent? That is the value which is larger than Decimal.MinValue and smaller than any other values that a decimal can represent. How can I obtain this value in C#? Thanks! 回答1: The second-minimum value is Decimal.MinValue + 1 . This can be inferred from the documentation for decimal : A decimal number is a floating-point value that consists of a sign, a numeric value where each digit in the value ranges from 0 to 9, and a scaling factor

Use comma for decimals and period for thousands rdlc report

假如想象 提交于 2019-12-07 16:12:24
问题 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

PostgreSQL数值类型--浮点类型和序列

天大地大妈咪最大 提交于 2019-12-07 15:53:34
PostgreSQL包括整数类型和浮点数类型。 整数类型包括3种,分别是smallint、int和bigint。别名分别是int2、int(int4)和int8.常用数据类型是int(integer)。 浮点类型分为精确浮点数类型numeric和不精确浮点数类型real(单精度浮点数据类型)和 double precision(双精度浮点数据类型)。 精确浮点数类型可以用numeric(precision, scale)表示。 精度(precision)必须是正值,标度(scale)为零或正值。类型numeric和decimal等价,都符合SQL标准。 numeric不带精度和标度,则系统使用任意精度,不会超过数据库系统储存范围。创建表显示声明精度最大值为1000。 numeric(precision, 0)等价于numeric(precision)。 ---不限定精度和标度 postgres=# create table testdecimal(id int,testvalue decimal); CREATE TABLE postgres=# insert into testdecimal values(1,777777777.77777777); INSERT 0 1 postgres=# insert into testdecimal values(1,777777777

Setting specific bits in a number

喜你入骨 提交于 2019-12-07 15:05:02
问题 var d = 7; in binary: 7 = (111) What I want to do is to set second place from right to 1 or 0 at disposal, and return the decimal value. For example,if I want to make the second 1 to 0,then after process should return a 5, because 5=(101). How to implement this in javascript? EDIT the answer should be something like this: function func(decimal,n_from_right,zero_or_one) { } Where decimal is the number to be processed, n_from_right is how many bits from right,in my example above it's 2. zero_or

change decimal point to comma in matplotlib plot

别来无恙 提交于 2019-12-07 13:57:57
问题 I'm using python 2.7.13 with matplotlib 2.0.0 on Debian. I want to change the decimal marker to a comma in my matplotlib plot on both axes and annotations. However the solution posted here does not work for me. The locale option changes successfully the decimal point but does not imply it in the plot. How can I fix it? I would like to use the locale option in combination with the rcParams setup. Thank you for your help. #!/usr/bin/env python # -*- coding: utf-8 -*- import numpy as np #Locale

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

天涯浪子 提交于 2019-12-07 13:35:43
问题 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

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

妖精的绣舞 提交于 2019-12-07 12:12:30
问题 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