number-formatting

Write a number with two decimal places SQL server

梦想的初衷 提交于 2019-12-17 03:57:50
问题 How do you write a number with two decimal places for sql server? 回答1: try this SELECT CONVERT(DECIMAL(10,2),YOURCOLUMN) 回答2: Use Str() Function. It takes three arguments(the number, the number total characters to display, and the number of decimal places to display Select Str(12345.6789, 12, 3) displays: ' 12345.679' ( 3 spaces, 5 digits 12345, a decimal point, and three decimal digits (679). - it rounds if it has to truncate, (unless the integer part is too large for the total size, in

Excel Number Format: What is “[$-409]”?

南楼画角 提交于 2019-12-17 03:08:54
问题 i'm automating excel, using the macro system as a guide to what i should do through automation. When i format a column as a date, the macro generated a NumberFormat for the column to be: [$-409]m/d/yy h:mm AM/PM;@ i'm trying to decipher what this really means. i gather from googling, that the values in the square brackets are a "condition" , and that if the condition: $-409 is met, then it will use the NumberFormat m/d/yy h:mm AM/PM if not, it uses the NumberFormat @ The references i find say

Format Number like Stack Overflow (rounded to thousands with K suffix)

谁说我不能喝 提交于 2019-12-17 03:02:15
问题 How to format numbers like SO with C#? 10, 5k, ... 回答1: Like this: ( EDIT : Tested) static string FormatNumber(int num) { if (num >= 100000) return FormatNumber(num / 1000) + "K"; if (num >= 10000) { return (num / 1000D).ToString("0.#") + "K"; } return num.ToString("#,0"); } Examples: 1 => 1 23 => 23 136 => 136 6968 => 6,968 23067 => 23.1K 133031 => 133K Note that this will give strange values for numbers >= 10 8 . For example, 12345678 becomes 12.3KK . 回答2: The code below is tested up to int

How to go about formatting 1200 to 1.2k in java

不想你离开。 提交于 2019-12-17 02:25:49
问题 I'd like to format following numbers into the numbers next to them with java: 1000 to 1k 5821 to 5.8k 10500 to 10k 101800 to 101k 2000000 to 2m 7800000 to 7.8m 92150000 to 92m 123200000 to 123m The number on the right will be long or integer the number on the left will be string. How should I approach this. I already did little algorithm for this but I thought there might be already something invented out there that does nicer job at it and doesn't require additional testing if I start

java : convert float to String and String to float

十年热恋 提交于 2019-12-16 22:22:49
问题 How could I convert from float to string or string to float? In my case I need to make the assertion between 2 values string (value that I have got from table) and float value that I have calculated. String valueFromTable = "25"; Float valueCalculated =25.0; I tried from float to string: String sSelectivityRate = String.valueOf(valueCalculated ); but the assertion fails 回答1: Using Java’s Float class. float f = Float.parseFloat("25"); String s = Float.toString(25.0f); To compare it's always

How can I parse a string with a comma thousand separator to a number?

ⅰ亾dé卋堺 提交于 2019-12-16 20:26:01
问题 I have 2,299.00 as a string and I am trying to parse it to a number. I tried using parseFloat , which results in 2. I guess the comma is the problem, but how would I solve this issue the right way? Just remove the comma? var x = parseFloat("2,299.00") alert(x); 回答1: Yes remove the commas: parseFloat(yournumber.replace(/,/g, '')); 回答2: Removing commas is potentially dangerous because, as others have mentioned in the comments, many locales use a comma to mean something different (like a decimal

Is there any way to generate ID combined with alphabets in java?

拥有回忆 提交于 2019-12-14 04:11:38
问题 I have created a students registration project and I need to give registration number on my own for those who are registering in my website. My Registration Id should be ABC0000001 so on. I tried this following code to generate reg no. for(int i=0000001;i<3;i++){ System.out.println("ABC"+i); } But I got output as ABC1 ABC2 ABC3. This is not needed. Please advice. 回答1: Numbers do not have significant leading zeros. (Never mind that the code actually uses an octal number literal in Java.) See

Looking for decimal to alphanumeric number base converter library in Visual Basic (or pseudo code algorithm) WITHOUT recursion

爷,独闯天下 提交于 2019-12-14 03:25:31
问题 I'm looking for a decimal to alphanumeric number base converter library in Visual Basic that does not use recursion. I found: http://visualstudiomagazine.com/articles/2010/07/20/when-hexadecimal-is-not-enough.aspx which includes a demo app but discovered that it uses recursion. The problem with it using recursion became apparent when I attempted to integrate the library into my own Visual Studio Express 2010 Visual Basic project: I got a stack overflow exception. Now I could consider

Excel interop adding slashes in my number formatting string

有些话、适合烂在心里 提交于 2019-12-14 03:14:42
问题 I'm trying to set a number format (South African Rand currency, no decimals) to a range like so: range.NumberFormat = "_ R * # ##0_;"; where range is of type Microsoft.Office.Interop.Excel.Range however when I open the spreadsheet and check the formatting string by choosing custom format the string now looks like this: _ \R * #\ ##0_; and these added slashes means that only the first thousand separator (a space) is present and the rest are left off. I've also tried this: range.NumberFormat =

Sum of Doubles that where parsed from a JTable

孤街醉人 提交于 2019-12-14 02:29:03
问题 How to get the sum of Doubles that where parsed from a JTable ? I'm Building a Client/Server Application, and I'm Stuck on a Little issue. I want get the sum of values of a column in a JTable , this column contains String objects with #,## format, so when I try to parse them into doubles with a loop I get this error: java.lang.NumberFormatException: For input string: "0,55" Here is the JTable image: And here is the code that I tried so far: private void jButton10ActionPerformed(java.awt.event