decimal-point

C# unlimited significant decimal digits (arbitrary precision) without java [duplicate]

≡放荡痞女 提交于 2020-01-27 08:42:10
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: what is the equivalent for java class : BigDecimal in c# I know in this post: Arbitrary precision decimals in C#? says to use java.math.BigDecimal, but I don't have J# installed. How would I achieve arbitrary precision in C#? I was thinking of using binary strings but I may run into some trouble when multiplying the two. 回答1: See What is the equivalent of the Java BigDecimal class in C#? You could create your

Using “Decimal” in Python

不羁岁月 提交于 2020-01-21 13:29:03
问题 Can someone please explain what's happening below: (I use Python 3.3) 1. >>> Decimal("0.1") + Decimal("0.1") + Decimal("0.1") - Decimal("0.3") Decimal('0.0') 2. >>> Decimal(0.1) + Decimal(0.1) + Decimal(0.1) - Decimal(0.3) Decimal('2.775557561565156540423631668E-17') 3. >>> Decimal(0.1 + 0.1 + 0.1 - 0.3) Decimal('5.5511151231257827021181583404541015625E-17') I know it has to do with floating point limitation, I'd be glad if someone can explain why What has the " " got to do with the

Using “Decimal” in Python

两盒软妹~` 提交于 2020-01-21 13:27:38
问题 Can someone please explain what's happening below: (I use Python 3.3) 1. >>> Decimal("0.1") + Decimal("0.1") + Decimal("0.1") - Decimal("0.3") Decimal('0.0') 2. >>> Decimal(0.1) + Decimal(0.1) + Decimal(0.1) - Decimal(0.3) Decimal('2.775557561565156540423631668E-17') 3. >>> Decimal(0.1 + 0.1 + 0.1 - 0.3) Decimal('5.5511151231257827021181583404541015625E-17') I know it has to do with floating point limitation, I'd be glad if someone can explain why What has the " " got to do with the

Using “Decimal” in Python

柔情痞子 提交于 2020-01-21 13:27:07
问题 Can someone please explain what's happening below: (I use Python 3.3) 1. >>> Decimal("0.1") + Decimal("0.1") + Decimal("0.1") - Decimal("0.3") Decimal('0.0') 2. >>> Decimal(0.1) + Decimal(0.1) + Decimal(0.1) - Decimal(0.3) Decimal('2.775557561565156540423631668E-17') 3. >>> Decimal(0.1 + 0.1 + 0.1 - 0.3) Decimal('5.5511151231257827021181583404541015625E-17') I know it has to do with floating point limitation, I'd be glad if someone can explain why What has the " " got to do with the

Ruby Regex to round trailing zeros

二次信任 提交于 2020-01-11 05:26:09
问题 I'm looking for a regex to remove trailing zeros from decimal numbers. It should return the following results: 0.0002300 -> 0.00023 10.002300 -> 10.0023 100.0 -> 100 1000 -> 1000 0.0 -> 0 0 -> 0 Basically, it should remove trailing zeros and trailing decimal point if the fraction part is 0. It should also return 0 when that's the value. Any thoughts? thanks. 回答1: Try the regex: (?:(\..*[^0])0+|\.0+)$ and replace it with: \1 A demo: tests = ['0.0002300', '10.002300', '100.0', '1000', '0.0', '0

Converting float to varchar with correct decimal separator

天涯浪子 提交于 2020-01-10 05:21:06
问题 Hi i'm living in austria and we use the , as decimal separator. It seems to be impossible to convert the float to varchar with the correct separator according to the language/collation setting? Is this a bug? set language german --makes no difference in this case declare @f float = 4.5 select @f --output in my management studio is 4,5 --according to the regional os settings this is correct select convert(varchar,@f) -- output: 4.5 not correct one solution, but not ideal I think select replace

How can I make a “working” repeating decimal representation of a rational number?

╄→尐↘猪︶ㄣ 提交于 2020-01-09 19:27:28
问题 I've figured out how to display the repeating part of a repeating decimal using OverBar. repeatingDecimal doesn't actually work as a repeating decimal. I'd like to make a variation of it that looks and behaves like a repeating decimal. Question How could I make a working repeating decimal representation (possibly using Interpretation[] )? Background Please excuse me if I ramble. This is my first question and I wanted to be clear about what I have in mind. The following will "draw" a repeating

how can i show an irrational number to 100 decimal places in python?

↘锁芯ラ 提交于 2020-01-09 04:50:12
问题 I am trying to find the square root of 2 to 100 decimal places, but it only shows to like 10 by default, how can I change this? 回答1: decimal module comes in handy. >>> from decimal import * >>> getcontext().prec = 100 >>> Decimal(2).sqrt() Decimal('1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573') 回答2: You can use the decimal module for arbitrary precision numbers: import decimal d2 = decimal.Decimal(2) # Add a context with an arbitrary

How to get and fix raw value of a cell that has #ERROR

夙愿已清 提交于 2020-01-06 08:47:07
问题 I have a problem when copy-pasting table data from a web page into Sheets, that the cell values which start with an equals sign ("=") and has wrong decimal delimiter (",") for the locale, for example =+90,00 causes Sheets to complain about #ERROR! - Formula parse error. Because I cannot change the source of the data easily and there is a lot of it, I cannot manually remove or change the characters that break the value thinking it is a formula. Therefore I have been looking for ways to get the

Same spreadsheet, same cell, but different results, with different user

断了今生、忘了曾经 提交于 2020-01-06 07:53:15
问题 I have a problem with Google sheets since today. The spreadsheet I use to get an amount from a different sheet (within the same spreadsheet). But the same sheet gives different results depending on who is the user. In the example in this image it's Cell J5 for user A it is € -50,00 but for user B it is € -5000,00 It seems something to do with value() (it's what I saw on twitter, as many people suffer from this problem since today) Once their function value is used. (To convert text to a