decimal

Scientific notation to decimal

亡梦爱人 提交于 2019-12-12 01:50:00
问题 I have a double and i am trying to convert it to a decimal. When i use decimalformat to achieve this i get the following: public void roundNumber(){ double d = 2.081641999208976E-4; JOptionPane.showMessageDialog(null,roundFiveDecimals(d)); } public double roundFiveDecimals(double d) { DecimalFormat df = new DecimalFormat("#.#####"); return Double.valueOf(df.format(d)); } I want the output to be .00021; however, i get 2.1E-4. Can anyone help explain how to get .00021 and not 2.1E-4? 回答1: You

change decimal place in textbox using numericUpDown

余生颓废 提交于 2019-12-12 01:24:26
问题 Im using Visual Studio 2010, windows form (c#). I need change decimals place of value in textbox using numericUpDown1. example: I tryed this code: private void numericUpDown1_ValueChanged(object sender, EventArgs e) { // tbxConvertito.Text = (decimal.Parse(tbxConvertito.Text) * 10m).ToString(); if (numericUpDown1.Value == 0) { int decimalPlace = 0; // Decimal xDecimal = decimal.Parse(tbxConvertito.text); decimal xDecimal = decimal.Parse(tbxConvertito.Text); tbxConvertito.Text = (Math.Round

Converting decimal to binary in java having trouble with reversing order

烈酒焚心 提交于 2019-12-12 01:04:08
问题 Hey so I'm taking my first cs course ever at my university its taught in java. I'm having trouble converting decimal to binary. I seem to be able to get the correct output but its in reverse order, and I have no idea how to put it in the correct order, here is what I've coded so far, import java.util.*; public class lab6 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a decimal number to convert to binary: "); int x = input.nextInt();

PHP Division Float Value WorkAround

北城以北 提交于 2019-12-11 19:59:38
问题 Kindly refer: PHP Division Float Value Issue With reference to the Question I have wrote the following code. Can this be done in different way or less code than this.? The following will help when any of the two given value are lesser than 1 with decimal values. Is this a good practice? <?php $First_Value = 0.005; $Second_Value = 0.1; // Check the First Value for Decimal $First_Whole = floor($First_Value); // 0 $First_Fraction = $First_Value - $First_Whole; // .005 // Check the Second Value

Objective-C - Get number of decimals of a double variable

自古美人都是妖i 提交于 2019-12-11 19:56:55
问题 Is there a nice way to get the number of decimals of a double variable in Objective-C? I am struggling for a while to find a way but with no success. For example 231.44232000 should return 5. Thanks in advance. 回答1: You could, in a loop, multiply by 10 until the fractional part (returned by modf()) is really close to zero. The number of iterations'll be the answer you're after. Something like: int countDigits(double num) { int rv = 0; const double insignificantDigit = 8; double intpart,

How to round a Python Decimal to 2 decimal places?

断了今生、忘了曾经 提交于 2019-12-11 19:27:23
问题 I've got a python Decimal (a currency amount) which I want to round to two decimal places. I tried doing this using the regular round() function. Unfortunately, this returns a float, which makes it unreliable to continue with: >>> from decimal import Decimal >>> a = Decimal('1.23456789') >>> type(round(a, 2)) <type 'float'> in the decimal module, I see a couple things in relation to rounding: ROUND_05UP ROUND_CEILING ROUND_DOWN ROUND_FLOOR ROUND_HALF_DOWN ROUND_HALF_EVEN ROUND_HALF_UP ROUND

How to delete trailing zeros after the 3rd decimal place in PHP?

我怕爱的太早我们不能终老 提交于 2019-12-11 19:20:34
问题 thanks in advance. I have a WP WooCommerce store and need to upload some prices that have 3 decimal places, e.g. £0.012 (products that are purchased in volumes of 000s). The majority of my products are 'ordinary' with 2 decimal places. There is a function in WooCommerce that allows for 3 decimal places - fine. Also a function to delete trailing zeros, but it deletes them if it's an integer e.g. £10.00 becomes £10. My problem arises when the 95% of 'ordinary' price products start showing £10

PHP Scientific Notation Shortening

谁都会走 提交于 2019-12-11 17:57:19
问题 I'm looking for an elegant solution here (if one exists). I've got a bunch of numbers, with an arbitrary amount of decimal places. I want to force the number to use 8 decimal places if it's got more than 8 trailing zeroes i.e. 0.000000004321 That would be converted to: 0.00000001 But I don't want to use number format because if I force it to 8 decimals with number format my numbers without 8 decimal places will look like: 1.00000000 I'd rather these just look like (for amounts >= 1): 1

how to convert binary to decimal in asm x86?

ぐ巨炮叔叔 提交于 2019-12-11 17:46:12
问题 I have no idea what is wrong with my coding in DISPLAY_IN_DECIMAL. They kept giving me this error. Assembling: coa.asm coa.asm(314) : error A2006:undefined symbol : decimalArray DISPLAY_IN_DECIMAL(3): Macro Called From coa.asm(314): Main Line Code Press any key to continue . . . I thought it might be something wrong with my decimalArray but I'm not sure what. This is the code part where I finish all of my binary display. Nothing seems wrong. counter db 0 X db 00000000B Y db 00000000B