decimal

Python Pandas Decimal Mark EU to US

混江龙づ霸主 提交于 2019-12-11 01:34:42
问题 I red the mails about EU to US decimal mark conversion, these helped a lot, but I'm still feeling to need some help from the experts .. My datas are from an ERP system with numbers in the format like "1'000'000,32" and I'd like simply to convert into something like "1000000.32" for further processing in Pandas. My actual solution to obtain the US format starting from the EU looks like: ... # read_csv and merge, clean .. different CSV files # result = merge (some_DataFrame_EU_format, ...) ...

Enforcing the number of decimal places when printing results

ε祈祈猫儿з 提交于 2019-12-11 00:31:54
问题 A different exercise. This one asked to evaluate the value of x for x-2=ln(x). There are two approaches (A and B) - one makes use of the given equation and yields the smaller solution (x1). The other approach uses e**(x-2)=x and yields the other solution (x2). Program plots the graphical solution and then queries for initial value input. Then it evaluates x using appropriate approaches. Approach A requires initial condition lesser than x2, approach B requires initial condition greater than x1

Difference when casting a datetime to a decimal on different SQL servers

社会主义新天地 提交于 2019-12-11 00:16:03
问题 On two different sql servers I run the following query: declare @myDatetime as datetime = '2017-07-04 23:42:32.400' select CAST(@myDatetime AS DECIMAL(20,5)) I get two different results: 42918.98788 and 42918.98787 If I cast to a DECIMAL(20,6) it works fine (42918.987875) but let's say I need to put it in a decimal(20,5). Where can I found the source of this difference in behaviour when rounding? Is it an option somewhere that rounds the final 5 up or down? Is it a sort of locale,

How to move decimal?

穿精又带淫゛_ 提交于 2019-12-10 23:39:52
问题 In JavaScript, I want to define where the decimal place goes. I can only really show it in example. Lets say the input value is 1234 . I want the output to be 123.4 . Or, if the input is 12345 , I want the output to be 123.45 . Or, if the input is 123456 , I want the output to be 123.456 . You get the picture. To clarify, I just want three digits on the left side of the decimal. The total number of digits is unknown. So, how could this be done? 回答1: var n = 1234; var l = n.toString().length-3

Convert binary to hex to decimal

最后都变了- 提交于 2019-12-10 23:38:13
问题 I have the binary number 1010 1011. I know that this is AB in hex and I know that A = 10 and B = 11 in decimal. But how do I get from 10 and 11 in decimal to the final number of 171? With hex I would do A B 0xAB = (10 * 16^1) + (11 * 16^0) = 171 Can I do something similar with the decimal numbers to go from 10 and 11 to 171? Basically, I'm just looking for a fast way to convert any binary number without a calculator. 回答1: I don't think there's a much easier way than A × 16 + B. 回答2: Depending

Make TryParse compatible with comma or dot decimal separator

帅比萌擦擦* 提交于 2019-12-10 22:03:18
问题 The problem: Let's assume you are using a dot "." as a decimal separator in your regional setting and have coded a string with a comma. string str = "2,5"; What happens when you decimal.TryParse(str, out somevariable); it? somevariable will assume 0. What can you do to solve it? 1- You can decimal.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out somevariable); And it will return 25, and not 2.5 which is wrong. 2- You can decimal.TryParse(str.Replace(",","."), out num); And it

Decimal precision loss when trying to calculate fractions of a box

不打扰是莪最后的温柔 提交于 2019-12-10 21:35:53
问题 I have a scenario where I have a standard box that contains 3 cans. For display and query purposes I have to report in terms of a decimal amount of its standard configuration. It is not possible to say 1 box of 3 cans, 1 box of 2 cans...etc For example, initially I will have 1 box of 3 cans I then remove 1 can resulting in 0.66 recurring box of 3 cans I then remove 1 more can resulting in 0.33 recurring box of 3 cans I then remove the final can resulting in 0.0000000000000000000000000001 box

Render JavaScript number as solidity ERC20 decimals

梦想与她 提交于 2019-12-10 20:41:56
问题 When you create an ERC20 cryptocurrency in solidity you initialize it with a number of decimals. If you total supply is 10k and the number of decimals is 4, your token supply will display as 100000000 (10,000.0000). In Solidity, you simply do YourNumber*10**4 to initialize a number like 10,000.0000 where YourNumber = 10,000 I wanted to do a simple calculator in JavaScript where, based on the user input we give them their input in decimals of a token. Say the maximum number of decimals is 4

Converting from `NSDecimal` or `NSDecimalNumber` to C#'s `decimal` type

狂风中的少年 提交于 2019-12-10 18:49:27
问题 I've got an NSDecimalNumber from StoreKit's SKProduct class, and I want to convert it to C#'s decimal type to minimize loss of precision. Is there a straightforward way to do such a thing? I figure my two choices are: Assume that I understand the binary implementation of each and do my own bit-wise conversion, or Have NSDecimalNumber give me a string and then have decimal parse it. I figure option 1 is way too much work and probably even brittle, so I'm inclined to go with option 2. But that

Compare decimals in python

若如初见. 提交于 2019-12-10 18:08:44
问题 I want to be able to compare Decimals in Python. For the sake of making calculations with money, clever people told me to use Decimals instead of floats, so I did. However, if I want to verify that a calculation produces the expected result, how would I go about it? >>> a = Decimal(1./3.) >>> a Decimal('0.333333333333333314829616256247390992939472198486328125') >>> b = Decimal(2./3.) >>> b Decimal('0.66666666666666662965923251249478198587894439697265625') >>> a == b False >>> a == b - a False