Search Results

Search found 1193 results on 48 pages for 'decimal'.

Page 5/48 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • BigInteger.ToString() returns more than 50 decimal digits.

    - by brickner
    I'm using .NET 4 System.Numerics.BigInteger Structure and I'm getting results different from the documentation. In the documentation of BigInteger.ToString() Method It says: The ToString() method supports 50 decimal digits of precision. That is, if the BigInteger value has more than 50 digits, only the 50 most significant digits are preserved in the output string; all other digits are replaced with zeros. I have some code that takes a 60 decimal digits BigInteger and converts it to a string. The 60 significant decimal digits string didn't lose any significant digits: const string vString = "123456789012345678901234567890123456789012345678901234567890"; Assert.AreEqual(60, vString.Length); BigInteger v = BigInteger.Parse(vString); Assert.AreEqual(60, v.ToString().Length); Assert.AreEqual('9', v.ToString()[58]); Assert.AreEqual('1', v.ToString()[0]); Assert.AreEqual(vString, v.ToString()); All the asserts pass. What exactly does the quoted part of the documentation mean?

    Read the article

  • Regular Expression for Decimal or Blank

    - by Phil P
    Sorry for the potentially dumb question but I am trying to pull together a regular expression that will allow: A number with 1 or 2 numbers before a decimal point, and 0-6 numbers after the decimal point. However I also need to allow the field to be blank if so required. Valid Examples 0.952321 1.20394 12.12 25 Blank Invalid Examples 123.45678 1.1234567 Please can anyone help?

    Read the article

  • Avoid compiling when using Decimal.Round() method (C#/CF)

    - by Christian Almeida
    Is there a way to tell to VS2005 to get compiler error when using "some defined" method? It probably sounds strange, but I do not want to compile when using Decimal.Round(). Reason: CF does not round by "awayfromzero", so I created a method to do this job. But sometimes I (and team) forget that is not to use Decimal.Round. So I'd like to get a compiler error when using it.

    Read the article

  • Change the precision of all decimal columns in every table in the database

    - by Jon
    Hi all, I have a rather large database that has alot of decimal columns in alot of tables, the customer has now changed their mind and wants all the numbers (decimals) to have a precision of 3 d.p. instead of the original two. Is there any quick way of going through all the tables in a database and changing any decimal column in that table to have 3.d.p instead of 2 d.p? The db is on sql 2005. Any help would be great.

    Read the article

  • "For money, always decimal" ???

    - by Dryadwoods
    Well, the rule "For money, always decimal" isn't applied inside the Microsoft development team, because if it was: Namespace: Microsoft.VisualBasic Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll) Financial.IPmt and all the other methods would receive/return decimal and not double as it is. Now I wonder if I can use this methods without worry with round mistakes? Should I use some other libraries to work with finances? If yes, could you point me some good ones (for C# use) ? Thank you.

    Read the article

  • Simple regular expression for decimal numbers?

    - by finch
    I know this may be the simplest question ever asked on Stack Overflow, but what is the regular expression for a decimal with a precision of 2? Valid examples: 123.12 2 56754 92929292929292.12 0.21 3.1 Invalid examples: 12.1232 2.23332 e666.76 Sorry for the lame question, but for the life of me I haven't been able to find anyone that can help! The decimal place may be option, and that integers may also be included.

    Read the article

  • Double.ToString with N Number of Decimal Places

    - by Ngu Soon Hui
    I know that if we want to display a double as a two decimal digit, one would just have to use public void DisplayTwoDecimal(double dbValue) { Console.WriteLine(dbValue.ToString("0.00")); } But how to extend this to N decimal places, where N is determined by the user? public void DisplayNDecimal(double dbValue, int nDecimal) { // how to display }

    Read the article

  • Ruby on Rails - Currency : commas causing an issue.

    - by easement
    Looking on SO, I see that the preferred way to currency using RoR is using decimal(8,2) and to output them using number_to_currency(); I can get my numbers out of the DB, but I'm having issues on getting them in. Inside my update action I have the following line: if @non_labor_expense.update_attributes(params[:non_labor_expense]) puts YAML::dump(params) The dump of params shows the correct value. xx,yyy.zz , but what gets stored in the DB is only xx.00 What do I need to do in order to take into account that there may be commas and a user may not enter .zz (the cents). Some regex and for comma? how would you handle the decimal if it were .2 versus .20 . There has to be a builtin or at least a better way. My Migration (I don't know if this helps): class ChangeExpenseToDec < ActiveRecord::Migration def self.up change_column :non_labor_expenses, :amount, :decimal, :precision => 8, :scale => 2 end def self.down change_column :non_labor_expenses, :amount, :integer end end

    Read the article

  • Bladecenter-E Power Module fault

    - by Lihnjo
    We have problem on IBM Bladecenter-E Critical Events Power module 2 is off. DC fault. Power module 4 is off. DC fault. Warnings and System Events Insufficient chassis power to support redundancy What is the best solution for this problem? Thanks AMM Service Data Help SPAPP Capture Available 10/13/2010 17:03:47 1090347 bytes Time: 11/19/2012 11:02:31 UUID: 42E1 5D2F D7BF 41A6 A4A2 48D1 3FB7 0540 MAC Address xx:xx:xx:xx:xx:xx MM Information Name: nnnnn Contact: aaa, bbb, ccc, England Location: [email protected] IP address: 111.222.333.444 Date Time Information GMT offset: +1:00 - Central Europe Time (Western Europe, Algeria, Nigeria, Angola) Adjust for DST: Yes NTP: Enabled NTP Hostname/IP: 111.222.333.444 System Health: Critical System Status Summary One or more monitored parameters are abnormal. Critical Events Power module 2 is off. DC fault. Power module 4 is off. DC fault. Warnings and System Events Insufficient chassis power to support redundancy CHASSIS (BladeCenter-E) in CHASSIS slot: 01 TopoPath is "CHASSIS[1]". Description : BladeCenter-E Width : 1 Sub Type : BladeCenter (BC) Power Mode : 220 v KVM Owner : CHASSIS[1]/BLADE[9] MT Owner : CHASSIS[1]/MGMT_MOD[1] Component Type : CHASSIS Inventory: VPD ID: 336 (decimal) POS ID EXT: 0 (decimal) POS ID: 8 (decimal) Machine Type/Model: 86773RG Machine Serial Number: 99ZL816 Part Number: 39R8561 FRU Number: 39R8563 FRU Serial Number: YK109174W1HV Manufacturer ID: IBM Hardware Revision: 3 (decimal) Manufacture Date: 18 (wk), 07 (yr) UUID: 42E1 5D2F D7BF 41A6 A4A2 48D1 3FB7 0540 (hex) Type Code: 97 (decimal) Sub-type Code: 0 (decimal) IANA Num: 336 (decimal) Product ID: 8 (decimal) Manufacturer Sub ID: FOXC Enviroment data: -------------- Type: : POWER_USAGE Unit: : WATTS Reading: : 0xa Sensor Label: : Midplane Sensor ID: : 0x0 MGMT MOD (Advanced Management Module) in MGMT_MOD slot: 01 TopoPath is "CHASSIS[1]/MGMT_MOD[1]". Description : Advanced Management Module Name : kant Width : 1 Component Role : Primary Component Type : MGMT MOD Insert Time : 28050132 Inventory: VPD ID: 288 (decimal) POS ID EXT: 0 (decimal) POS ID: 4 (decimal) Part Number: 39Y9659 FRU Number: 39Y9661 FRU Serial Number: YK11836CE2RC Manufacturer ID: IBM Hardware Revision: 4 (decimal) Manufacture Date: 50 (wk), 06 (yr) UUID: 1D95 9937 8CA5 11DB 9499 0014 5EDF 1C98 (hex) Type Code: 81 (decimal) Sub-type Code: 1 (decimal) IANA Num: 20301 (decimal) Product ID: 65 (decimal) Manufacturer Sub ID: ASUS Firmware data: Type : AMM firmware Build ID : BPET50P File Name : CNETCMUS.PKT Release Date : 03/26/2010 Release Level : 50 Revision - Major: 80 Port info: ======================================================== Topology Path ID : 1 Label : External Phy Orientation : EXTERNAL Port Number : 1 Type : MGT Physical Meidum : Copper Number of Link Intferfaces : 1 ------------------------------------ Link Ifc ID Number : 1 Link Ifc Transport Protocol : ENET Link Ifc Addr Type : MAC Link Ifc Burned-in Addr : xx:xx:xx:xx:xx:xx Link Ifc Admin Addr : 00:00:00:00:00:00 Link Ifc Addr in use : xx:xx:xx:xx:xx:xx ---------------------------------------------------------- Configuration behaviors: Save Only Enviroment data: -------------- Type: : TEMPERATURE Unit: : DEGREES_C Reading: : 38.00 Sensor Label: : MM Ambient Sensor ID: : 0x0 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +4.81 Sensor Label: : +5V Sensor ID: : 0x1b -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +3.26 Sensor Label: : +3.3V Sensor ID: : 0x19 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +11.97 Sensor Label: : +12V Sensor ID: : 0x16 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : -4.88 Sensor Label: : -5V Sensor ID: : 0x1e -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +2.47 Sensor Label: : +2.5V Sensor ID: : 0x18 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +1.76 Sensor Label: : +1.8V Sensor ID: : 0x15 -------------- Type: : POWER_USAGE Unit: : WATTS Reading: : 0x19 Sensor Label: : kant Sensor ID: : 0x0

    Read the article

  • Convert string to decimal retaining the exact input format

    - by Brett
    Hi All, I'm sure this is a piece of cake but I'm really struggling with something that seems trivial. I need to check the inputted text of a textbox on the form submit and check to see if it's within a desired range (I've tried a Range Validator but it doesn't work for some reason so I'm trying to do this server-side). What I want to do is: Get the value inputted (eg. 0.02), replace the commas and periods, convert that to a decimal (or double or equivalent) and check to see if it's between 0.10 and 35000.00. Here's what I have so far: string s = txtTransactionValue.Text.Replace(",", string.Empty).Replace(".", string.Empty); decimal transactionValue = Decimal.Parse(s); if (transactionValue >= 0.10M && transactionValue <= 35000.00M) // do something If I pass 0.02 into the above, transactionValue is 2. I want to retain the value as 0.02 (ie. do no format changes to it - 100.00 is 100.00, 999.99 is 999.99) Any ideas? Thanks in advance, Brett

    Read the article

  • Converting an input text value to a decimal number

    - by vitto
    Hi, I'm trying to work with decimal data in my PHP and MySql practice and I'm not sure about how can I do for an acceptable level af accuracy. I've wrote a simple function which recives my input text value and converts it to a decimal number ready to be stored in the database. <?php function unit ($value, $decimal_point = 2) { return number_format (str_replace (",", ".", strip_tags (trim ($value))), $decimal_point); } ?> I've resolved something like AbdlBsF5%?nl with some jQuery code for replace and some regex to keep only numbers, dots and commas. In some country, people uses the comma , to send decimal numbers, so a number like 72.08 is wrote like 72,08. I'd like avoid to forcing people to change their usual chars and I've decided to use a jQuery to keep this too. Now every web developer knows the last validation must be handled by the dynamic page for security reasons. So my answer is should I use something like unit (); function to store data or shoul I also check if users inserts invalid chars like letters or something else? If I try this and send letters, the query works without save the invalid data, I think this isn't bad, but I could easily be wrong because I'm a rookie. What kind of method should I use if I want a number like 99999.99 for my query?

    Read the article

  • T SQL Rotate row into columns

    - by cshah
    SQL 2005 using T-SQL, I want to rotate rows into columns. Sample script: Use TempDB Go CREATE TABLE [dbo].[CPPrinter_InkLevels]( [CPPrinter_InkLevels_ID] [int] IDENTITY(1,1) NOT NULL, [CPMeasurementGUID] [uniqueidentifier] NOT NULL, [InkName] [varchar](30) NOT NULL, [InkLevel] [decimal](6, 2) NOT NULL, CONSTRAINT [PK_CPPrinter_InkLevels] PRIMARY KEY CLUSTERED ( [CPPrinter_InkLevels_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[CPPrinter_InkLevels] ON INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (1, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Black', CAST(0.60 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (2, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Cyan', CAST(0.69 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (3, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Magenta', CAST(0.55 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (4, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Yellow', CAST(0.51 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (5, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Light Black', CAST(0.64 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (6, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Light Cyan', CAST(0.43 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (7, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Light Magenta', CAST(0.30 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (8, N'6acc1562-4e02-45ff-b480-9e01fb97fccf', N'Waste Tank', CAST(0.18 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (9, N'932348a7-6e2f-4a10-9760-be1ae640c7d7', N'Black', CAST(0.60 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (10, N'932348a7-6e2f-4a10-9760-be1ae640c7d7', N'Cyan', CAST(0.69 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (11, N'932348a7-6e2f-4a10-9760-be1ae640c7d7', N'Magenta', CAST(0.55 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (12, N'932348a7-6e2f-4a10-9760-be1ae640c7d7', N'Yellow', CAST(0.51 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (13, N'932348a7-6e2f-4a10-9760-be1ae640c7d7', N'Light Black', CAST(0.64 AS Decimal(6, 2))) INSERT [dbo].[CPPrinter_InkLevels] ([CPPrinter_InkLevels_ID], [CPMeasurementGUID], [InkName], [InkLevel]) VALUES (14, N'932348a7-6e2f-4a10-9760-be1ae640c7d7', N'Light Cyan', CAST(0.43 AS Decimal(6, 2))) Go SELECT * FROM [dbo].[CPPrinter_InkLevels] --Desired output CPMeasuremnetGUID, Ink1, Level1, Ink2, Level2, Ink3, Level3....

    Read the article

  • Django custom SQL returning single row of results when query returns 2?

    - by Alvin
    I have a custom SQL call that is returning different results to the template than I get when I run the same query against the database directly, 1 row vs 2 Query - copied from Django Debug Toolbar: SELECT ((Sum(new_recruit_interviews) / Sum(opportunities_offered)) * 100) as avg_recruit, ((Sum(inspections) / Sum(presentations)) * 100) as avg_inspect, ((Sum(contracts_signed) / Sum(roof_approvals)) * 100) as avg_contracts, ((Sum(adjusters) / Sum(contracts_signed)) * 100) as avg_adjusters, ((Sum(roof_approvals) / Sum(adjusters)) *100) as roof_approval_avg, ((Sum(roof_turned_in) / Sum(adjusters)) * 100) as roof_jobs_avg, Sum(roof_turned_in) as roof_jobs_total, ((Sum(siding_approvals) / Sum(adjusters)) *100) as siding_approval_avg, ((Sum(siding_turned_in) / Sum(adjusters)) * 100) as siding_jobs_avg, Sum(siding_turned_in) as siding_jobs_total, ((Sum(gutter_approvals) / Sum(adjusters)) *100) as gutter_approval_avg, ((Sum(gutter_turned_in) / Sum(adjusters)) * 100) as gutter_jobs_avg, Sum(gutter_turned_in) as gutter_jobs_total, ((Sum(window_approvals) / Sum(adjusters)) *100) as window_approval_avg, ((Sum(window_turned_in) / Sum(adjusters)) * 100) as window_jobs_avg, Sum(window_turned_in) as window_jobs_total, (Sum(roof_turned_in) + Sum(siding_turned_in) + Sum(gutter_turned_in) + Sum(window_turned_in)) as total_jobs, (((Sum(collections_jobs_new) + Sum(collections_jobs_previous)) / (Sum(roof_turned_in) + Sum(siding_turned_in) + Sum(gutter_turned_in) + Sum(window_turned_in))) * 100) as total_collections, sales_report_salesmen.location_id as detail_id, business_unit_location.title as title FROM sales_report_salesmen Inner Join auth_user ON sales_report_salesmen.user_id = auth_user.id Inner Join business_unit_location ON sales_report_salesmen.location_id = business_unit_location.id GROUP BY location_id Results from direct query running the above query: INSERT INTO `` (`avg_recruit`, `avg_inspect`, `avg_contracts`, `avg_adjusters`, `roof_approval_avg`, `roof_jobs_avg`, `roof_jobs_total`, `siding_approval_avg`, `siding_jobs_avg`, `siding_jobs_total`, `gutter_approval_avg`, `gutter_jobs_avg`, `gutter_jobs_total`, `window_approval_avg`, `window_jobs_avg`, `window_jobs_total`, `total_jobs`, `total_collections`, `detail_id`, `title`) VALUES (95.3968, 92.8178, 106.9622, 90.2928, 103.5420, 103.5670, 4152, 100.2494, 106.8845, 4285, 120.1297, 86.2559, 3458, 92.9658, 106.1611, 4256, 16151, 4.281469, 12, 'St Paul, MN'); VALUES (90.2982, 73.3723, 97.8474, 104.5433, 97.7585, 86.1848, 1884, 109.9268, 109.3321, 2390, 81.0156, 96.4318, 2108, 91.7200, 123.8792, 2708, 9090, 4.531573, 13, 'Denver, CO'); Results from template: {'roof_jobs_total': Decimal('4152'), 'gutter_jobs_total': Decimal('3458'), 'avg_adjusters': Decimal('90.2928'), 'title': u'St Paul, MN', 'window_approval_avg': Decimal('92.9658'), 'total_collections': Decimal('4.281469'), 'gutter_approval_avg': Decimal('120.1297'), 'avg_recruit': Decimal('95.3968'), 'siding_approval_avg': Decimal('100.2494'), 'window_jobs_total': Decimal('4256'), 'detail_id': 12L, 'siding_jobs_avg': Decimal('106.8845'), 'avg_inspect': Decimal('92.8178'), 'roof_approval_avg': Decimal('103.5420'), 'roof_jobs_avg': Decimal('103.5670'), 'total_jobs': Decimal('16151'), 'window_jobs_avg': Decimal('106.1611'), 'avg_contracts': Decimal('106.9622'), 'gutter_jobs_avg': Decimal('86.2559'), 'siding_jobs_total': Decimal('4285')} Tried tweaking it a few ways and running the results through various for loops, keep getting the same result where my results are a single row through the Django template and the expected results (through console) have 2 rows The row that is coming back is the same as the first row returned through the console query so I'm thinking that it is running correctly just a matter of passing the results through... for good measure this is the code I'm using to generate the query (yes it's a bit ugly, been playing with it) def sql_grouped(table, fields, group_by=False, where=False): from django.db import connection query = 'SELECT %s FROM %s' % (fields, table) if where: query = query + ' WHERE %s' % (where) if group_by: query = query + ' GROUP BY %s' % (group_by) cursor = connection.cursor() cursor.execute(query) desc = cursor.description data = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()] return data[0] any feedback is greatly appreciated - been tinkering with this since I realized I could skip a few steps by generating my averages directly within the SQL rather than post-process

    Read the article

  • NamedParameterJdbcTemplate jconnect decimal issue

    - by user1052849
    I am using NamedParameterJdbcTemplate to insert data into a table. (Spring 2.5.3/Java 1.6) I am using jconnect driver to connect to sybase jdbc:sybase:Tds:<Server>:<Port>. For some reason the decimal values the decimal part is truncated. With the same code if I use jtds driver (jdbc:jtds:sybase://<Servername>:<Port>) its working fine. I cannot use jtds as jconn is being used by other code. In Java objects, field is defined as double. In database, field is defined as float (numeric with precision does not work). Any help is appreciated.

    Read the article

  • Crystal report - Conversion from text to decimal ?

    - by 123rmn
    I have a crystal report, which takes data from an XML template. For a particular field of report, say 'Cost' the database stored procedure send data to XSD file in decimal format , but when the crystal report displays data picking from XSD, it is rounded off. When i right click on other data fields of report, I can see 'Field:table1.columnname',. But when i click on 'Cost' field, it shows 'Text:'. To my understanding, this is a text field which is mapped to pick data from XSD and since the type is text, it gives result in text hence truncating the decimal. Please suggest how can I get decimals here. P.S: This code was created by someone else, so i have no idea on what they had set at that time. I have to fix it and i have no clue about it.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >