decimal

(vb.net) rounding to 2 decimal places

痴心易碎 提交于 2020-05-23 11:32:22
问题 I am creating a program for a project that will help me learn visual basic. But when I work out how much a certain material is worth with dimensions. It come out with more than two decimal places. I know how to use math.floor function but it doesn't round to 2 decimal places. Does anyone know what function I should use to round to two decimal places? 回答1: The Decimal.Round method will do the trick for you. You can specify the number of decimal places. 回答2: You can use; Math.Round([DECIMAL], 2

Convert base 10 to base 2 in SQL Server for very large numbers

断了今生、忘了曾经 提交于 2020-05-17 07:04:39
问题 On SQL Server 2017 I have a base 10 number of type DECIMAL(38,0) which I need to convert to its base 2 representation. This works fine for smaller numbers, but fails with the target order of magnitude: DECLARE @var1 DECIMAL(38, 0) = 2679226456636072036565806253187530752; WITH A AS (SELECT @var1 AS NUMBER, CAST('' AS VARCHAR(125)) AS BITS UNION ALL SELECT CAST(ROUND(NUMBER / 2, 0, 1) AS DECIMAL(38, 0)), CAST(BITS + CAST(NUMBER % 2 AS VARCHAR(125)) AS VARCHAR(125)) FROM A WHERE NUMBER > 0)

Increasing a number based on a decimal less than 100?

耗尽温柔 提交于 2020-05-14 03:44:10
问题 I'm currently working on some SUMIF formulae which will calculate certain values against specific conditions. All of the values to be calculated are decimalised but are based on 0.80 = 1.00. As an example if I have 1.25 and 1.60 to add together I would want the outcome to read 3.05 but currently, I would get an outcome of 2.85. Is it possible to amend the highest number a decimal can read before it converts to 1? Hope this makes sense. 回答1: try: =ARRAYFORMULA(SUM(QUOTIENT(D1:D3, 1))+ QUOTIENT

Woocommerce decimal quantity

一笑奈何 提交于 2020-05-12 02:51:45
问题 can you help me to find a way for use decimal value like 3.56 for quantity in woocommerce ? in calculate price quantity number convert to Integers value but i need price calculate with Values that the user has inputed i am working with woocommerce 2.2.8 回答1: You have to add some functions, for some of the hooks i WooCommerce. // Add min value to the quantity field (default = 1) add_filter('woocommerce_quantity_input_min', 'min_decimal'); function min_decimal($val) { return 0.1; } // Add step

How to set space separator to float DecimalFormat?

▼魔方 西西 提交于 2020-04-10 18:46:31
问题 How to set space as thousand separator for DecimalFormat in float? I want to show 13,52 as 13,5, but 13,00 as 13 and I did this with new DecimalFormat("#.#").format(fIncome) but I want to 1400,5 be 1 400,5 and 1400 to be 1 400. For double I use this code (I don't want to shows numbers after comma in dCount): String.format("%,d", (int)dCount) But how to use this for floating number with 1 number after comma? 回答1: The accepted answer probably lacks a few lines of code, because it doesn't work

How do I add binary numbers using ARM Assembly?

泪湿孤枕 提交于 2020-03-04 19:35:49
问题 The assembly language that I"m using is ARM Assembly. Would I use the ADD instruction to do so? Would I have to start by taking in a number in decimal and then using some instruction to convert the decimal number to binary? Let's say that I have three numbers 33, 25, and 14. I want to add them all together. Say that the three numbers are stored in an 8-bit array with binary numbers with three elements. After traversing through the array, would I have to convert the binary numbers to decimal

how to test if a number is divisible by a decimal less than 1? (54.10 % .10)

匆匆过客 提交于 2020-02-25 17:00:08
问题 I'm trying to test if a float i.e( 54.10 ) is divisible by 0.10 . 54.10 % .10 returns .10 and not 0 , why is that and how can I get it to do what I want it to do? 回答1: You can use the decimal module to avoid the floating point precision problem: >>> import decimal >>> decimal.Decimal('54.10') % decimal.Decimal('0.10') Decimal('0.00') 回答2: The tried and true method here is to multiply your divisor and dividend by a power of 10. Effectively, 54.10 becomes 541 and 0.10 becomes 1. Then you can

How can i get Oracle number values to .NET without Zeros?

瘦欲@ 提交于 2020-02-25 08:37:42
问题 i try to read Data from an Oracle-Database. The problem is that in some cases the receiving data adds Zeros after the digit and i dont know why this happens?!? For example i want to read Data like this 1 1,1 1,12 1,123 When i read it with Oracle-Datareader i get 1 1,10 <- 1,12 1,1230 <- Everytime the decimal places are 1,3,5,7 long it adds one 0 in the result. But why is this happening?? Does anyone know this kind of problem? EDIT: Dim cmd As OracleCommand = New OracleCommand(Select_Statement

How to convert NumberDecimal to Double in MongoDB shell?

心不动则不痛 提交于 2020-02-25 08:22:29
问题 I have a document with "test" filed as NumberDecimal type { "_id" : ObjectId("5d1a202e476381c30cd995a4"), "test" : NumberDecimal("0.1") } How to convert "test" field from NumberDecimal to Double in mongodb shell? I tried execute db.collection.find({"test": {$exists: true}}).forEach(function (x) { x.test = parseFloat(x.test); db.collection.save(x); }); but don't solve this problem because it return NaN 回答1: The decimal type is not native to JavaScript, so NumberDecimal values in the shell are

Python Decimal module doesn't work on uint64

妖精的绣舞 提交于 2020-02-25 02:07:51
问题 I'm trying to convert a numpy.uint64 (which is outputted by numpy.sum()) to a decimal without losing precision with the Decimal module. >>> from decimal import Decimal >>> import numpy as np >>> >>> sum = np.sum(1000000000000000000) >>> type(sum) <type 'numpy.int64'> >>> Decimal(sum) Decimal('1000000000000000000') >>> >>> sum = np.sum(1000000000000000000000) >>> type(sum) <type 'long'> >>> Decimal(sum) Decimal('1000000000000000000000') >>> >>> sum = np.sum(10000000000000000000) >>> type(sum)