decimal

Deconstructing Pokémon glitches?

谁说我不能喝 提交于 2019-12-02 18:52:02
(I apologize if this is the wrong place to ask this. I think it's definitely programming related, though if this belongs on some other site please let me know) I grew up playing Pokémon Red and Blue, games that were great fun but are somewhat notorious for having numerous exploitable glitches (for example, see this ridiculous speedrun of the game that uses memory corruption to turn the item screen into a hex editor). Recently, I found an interesting speedrun of the game that uses a glitch called the "ZZAZZ glitch" to corrupt important memory locations and allow the player to almost immediately

How to insert DECIMAL into MySQL database

旧街凉风 提交于 2019-12-02 17:31:49
I have a database table with some fields, one of them, cost , is set to the DECIMAL data type. I set the parameters to 4,2 , which should allow 4 numbers before the decimal point, and 2 afterwards. (I've been told that the 4 here is the total amount, and the 2 is the amount after the decimal, could somebody please clear that up on a side note?) When I insert data via a POST request (the value 3.80 for example) the data stored to my database is actually 99.99 . What am I doing wrong to cause this? Here's the table: CREATE TABLE IF NOT EXISTS `mytable` ( `id` int(11) NOT NULL AUTO_INCREMENT,

How do I format a C# decimal to remove extra following 0's?

*爱你&永不变心* 提交于 2019-12-02 16:59:08
I want to format a string as a decimal, but the decimal contains some following zeros after the decimal. How do I format it such that those meaningless 0's disappear? string.Format("{0}", 1100M); string.Format("{0}", 1100.1M); string.Format("{0}", 1100.100M); string.Format("{0}", 1100.1000M); displays: 1100 1100.1 1100.100 1100.1000 but I want it to be: 1100 1100.1 1100.1 1100.1 For reference, here are other questions that are essentially duplicates of this, that I've found thanks to answers given here: Parse decimal and filter extra 0 on the right? Best way to display decimal without trailing

Program to convert binary to decimal in C#? [duplicate]

扶醉桌前 提交于 2019-12-02 15:06:06
This question already has an answer here: Binary to Decimal Conversion - Formula? 6 answers I'm wanting to create a basic program to enable me to convert binary numbers into decimal numbers, but having looked almost everywhere on the internet, I just can't find a solution to this that works! I can't seem to follow the solutions, So far I've developed a bit of code, but not sure if it is correct or not, any help? Thanks int iBinaryNum; //To store binary number string sDecimalNum; //To store decimal numbers Console.WriteLine("Enter the binary number you want to convert to decimal"); iBinaryNum =

user input value to use as decimal value python

笑着哭i 提交于 2019-12-02 13:56:38
问题 I am writing a python code where I ask the user for input and then I have to use their input to give the number of decimal places for the answer to an expression. userDecimals = raw_input (" Enter the number of decimal places you would like in the final answer: ") then I convert this to integer value userDecimals = int(userDecimals) then I write the expression, and I want the answer to have as many decimal places as the user input from UserDecimals, and I don't know how to accomplish this.

How to convert hexadecimal string to decimal?

。_饼干妹妹 提交于 2019-12-02 13:35:00
问题 I would appreciate it if you could tell me how I can convert hexadecimal letters within an NSString , e.g. @"50A6C2" , to decimals using Objective-C. Thanks in advance. 回答1: The easiest way is to use an NSScanner, specifically the methods scanHexInt: or scanHexLongLong: . Another possibility is to get the C string from the NSString and use C-style functions such as strtol (with base 16). 来源: https://stackoverflow.com/questions/6002196/how-to-convert-hexadecimal-string-to-decimal

Decimal to Octal Conversion [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 12:59:43
Possible Duplicate: Decimal Conversion error I am writing a program for a class and is having trouble figuring how to convert an octal number to an decimal number. Here is what I been trying to do so far: import java.util.Scanner; public class test { public static void main ( String args[]) { Scanner input = new Scanner(System.in); System.out.print("Enter number: "); int oct = input.nextInt(); int d2count = 0; int result=0; int d3count = 0; int d3 = 0; int d2 = 0; d3 = oct; d2 = oct; if(oct < 1000){ while ( d3 >= 100){ d3 = d3 - 100; d3count++; }} if (oct < 100){ while ( d2 >= 10){ d2 = d2 -

Python Decimal vs C# decimal precision [duplicate]

允我心安 提交于 2019-12-02 11:58:18
问题 This question already has answers here : Why python decimal.Decimal precision differs with equable args? (2 answers) Closed 2 years ago . I know this has been asked numerous times and I've come across many blogs and SO answers but this one's making me pull my hair out. I just want to multiply a two decimal number by 100 so I get rid of its decimals: >>> 4321.90 * 100 432189.99999999994 >>> Decimal(4321.90) * Decimal(100) Decimal('432189.9999999999636202119291') I'm scared to use rounding for

Round decimals in report formula

左心房为你撑大大i 提交于 2019-12-02 11:10:54
问题 My Crystal Report needs to round numbers to two decimal points. I have tried Round(55.815, 2) but it returns 55.81 instead of 55.82 . How can I resolve this? 回答1: just try this if Remainder(55.815 ,1) > 0.5 then Floor (55.815) + Remainder(55.815 ,1) else Floor (55.815 )+ Remainder(55.815 ,1) This may be help you 回答2: If you need to round the decimal for display purposes, simply use the "Decrease Decimals" icon: 来源: https://stackoverflow.com/questions/15462307/round-decimals-in-report-formula

Floating-point division in bash

久未见 提交于 2019-12-02 11:00:19
I'm trying to convert whatever numbers the user inputs into 2 decimal places. For instance What is the total cost in cents? 2345 output: 23.45 this is the code i have so far percentage=20 #cannot change numerical value must convert into 0.20 echo -n "What is the total cost? "; read cost_in_cents echo "scale 1; $cost_in_cents" | bc I'm also going to be doing some multiplication with percentage, how can i also convert the percentage into a float (0.20) Perhaps it's nostalgia for reverse polish notation desk calculators, but I'd use dc rather than bc here: dc <<<"2 k $cost_in_cents 100 / p"