decimal

Java code or lib to decode a binary-coded decimal (BCD) from a String

南楼画角 提交于 2019-12-13 13:18:21
问题 I have a string consisting of 1's ('\u0031') and 0's('\u0030') that represents a BCD value. Specifically, the string is 112 characters worth of 1's and 0's and I need to extract either 8 or 16 of these at a time and decode them from BCD to decimal. Ideas? Packages? Libs? Code? All is welcome. 回答1: Extracting 4 characters at a time and use Integer.parseInt(string, 2) should give each digit. Combine the digits as you see fit. 回答2: I think you're missing all the fun: Here's a basic

VBA changing decimal to comma automaticaly

北城以北 提交于 2019-12-13 12:31:30
问题 I have an Excel Macro in VBA. Yesterday everything worked fine, this morning VBA is taking a decimal point and changing the point to a comma. That is from 5.1 to 5,1. I am using a German system and have set in Excels advanced options that a point is a decimal and comma is thousands. For example I have a value for daily scrum meeting in the Excel sheet set at 3.75 Excel sheet input: when I use a function to read in the value such as: Sub TestFunction() MsgBox (Sheets("Input_Parameters").Cells

How to use Python to convert an octal to a decimal

余生颓废 提交于 2019-12-13 12:26:58
问题 I have this little homework assignment and I needed to convert decimal to octal and then octal to decimal. I did the first part and can not figure out the second to save my life. The first part went like this: decimal = int(input("Enter a decimal integer greater than 0: ")) print("Quotient Remainder Octal") bstring = " " while decimal > 0: remainder = decimal % 8 decimal = decimal // 8 bstring = str(remainder) + bstring print ("%5d%8d%12s" % (decimal, remainder, bstring)) print("The octal

Rounding a variable to two decimal places C# [duplicate]

Deadly 提交于 2019-12-13 11:51:49
问题 This question already has answers here : How do you round a number to two decimal places in C#? (15 answers) Closed 22 days ago . I am interested in how to round variables to two decimal places. In the example below, the bonus is usually a number with four decimal places. Is there any way to ensure the pay variable is always rounded to two decimal places? pay = 200 + bonus; Console.WriteLine(pay); 回答1: Use Math.Round and specify the number of decimal places. Math.Round(pay,2); Math.Round

How to convert hex to decimal in c#.net? [duplicate]

巧了我就是萌 提交于 2019-12-13 11:30:39
问题 This question already has answers here : How to convert numbers between hexadecimal and decimal (17 answers) Closed 4 years ago . Convert Hex to Decimal Example: It would ask a Hex. Shown below. Enter Hex: 8000 8000 1000 0100 Then, The Result: 32768 32768 4096 256 Convert each hex to decimal. HEX = DECIMAL 8000 = 32768 8000 = 32768 1000 = 4096 0100 = 256 回答1: use string.split(' ') to get your individual hex-numbers as a string-array. Then you can call int dec = int.Parse(hex, System

how to convert base10 decimal (big endian) to binary ( a hex in little endian) in a char array [closed]

爷,独闯天下 提交于 2019-12-13 10:52:24
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I'm having some trouble in iOS. I have been trying to convert a base10 decimal value into a little endian , hexadecimal string. So far I am unable to do so. For example I would like to convert the following

Restrict number of decimal places to two in Python float operations

淺唱寂寞╮ 提交于 2019-12-13 10:16:55
问题 My idea is accept a number as input, perhaps 1.00 and then multiply it by a constant. Subsequently it is passed to a function that determines whether or not it is a valid palindrome. In the case that it is not, the number will be incrementally augmented until a valid palindrome is achieved-- however, I'd like to restrict the exploration space to the 2nd decimal place. That is to say 1.01 is valid output, but 1.001 is not. The code that follows executes the process described above, with the

Decimal.ToUInt64 "Value was either too large or too small for a UInt64

此生再无相见时 提交于 2019-12-13 09:44:22
问题 I am doing: - Decimal production = 0; Decimal expense = 5000; Decimal.ToUInt64(production - expense); But it throws exception with the following error message. "Value was either too large or too small for a UInt64" Can someone give me a workaround for this. Thanks! Edit In any case, I want the result as a positive number. 回答1: Problem: -5000m is a negative number, which is outside the range of UInt64 (an unsigned type). Solution: use Int64 instead of UInt64 if you want to cope with negative

How to convert 2 restricted decimal variables to a third variable and vice versa?

谁说我不能喝 提交于 2019-12-13 09:26:12
问题 I have 2 convertor methods as below: private const decimal MaxValidValue = 99.99m; public decimal ConvertABToC(decimal a, decimal b) { return a * b; } public void ConvertCtoAB(decimal c, ref decimal a, ref decimal b) { if (c > MaxValidValue*MaxValidValue) { throw new ApplicationException(); } if (c <= MaxValidValue) { a = 1.00m; b = c; } else { // need to introduce some logic or assumptions here } } There are 3 important things to know: 1) The a and b variables are in the range of 0.00 to 99

Print out register in decimal without printf

旧巷老猫 提交于 2019-12-13 09:13:18
问题 I'm trying to print out value from register EDX on the screen. The program should find the maximum depth of paranthesis e.g for ((x)) EDX = 2 And I can't use stdlib. My program using stdlib .intel_syntax noprefix .globl main .text main: pop eax #return address pop eax #return argc pop eax #return argv mov eax,[eax+4] #argv[1] sub esp,12 #return stack to the right position lea ebx,[eax] xor eax,eax xor ecx,ecx xor edx,edx loop: mov al,[ebx] or al,al jz print cmp al,'(' je increase cmp al,')'