number-formatting

Change NSNumberFormatter's negative format from (xxx.xx) to -xxx.xx

不问归期 提交于 2020-01-10 19:26:55
问题 I want to change my NSNumberformatter from displaying negative numbers with parenthesis around them to putting the minus sign in front (or whatever the localized standard is). I would assume I could do this with setNegativeFormat: but reading Apple's oh so thorough docs I am left scratching my head: setNegativeFormat: Sets the format the receiver uses to display negative values. - (void)setNegativeFormat:(NSString *)aFormat Parameters aFormat A string that specifies the format for negative

MVC3 edit for decimal fields and localization

我怕爱的太早我们不能终老 提交于 2020-01-10 14:16:34
问题 My locale uses a comma , , and not a dot . for decimal separator. In MVC3, when I open an Edit view where the decimal values are shown with @Html.EditorFor(model => model.MyDecimalVal) the value is shown correctly. When I enter value with comma, I get error "Value is not a number" and if I enter value with dot, I get no error, but actually no value is saved. How to handle this situation? 回答1: Getting around with this by tweaking your validation logic has been already explained so here is a

Print Integer with 2 decimal places in Java

不打扰是莪最后的温柔 提交于 2020-01-10 01:02:48
问题 in my code i use integers multiplied by 100 as decimals (0.1 is 10 etc). Can you help me to format output to show it as decimal? 回答1: int x = 100; DecimalFormat df = new DecimalFormat("#.00"); // Set your desired format here. System.out.println(df.format(x/100.0)); 回答2: I would say to use 0.00 as format: int myNumber = 10; DecimalFormat format = new DecimalFormat("0.00"); System.out.println(format.format(myNumber)); It will print like: 10.00 The advantage here is: If you do like: double

Using Fractions On Websites

梦想与她 提交于 2020-01-09 12:02:06
问题 Is it possible to use any fraction symbol on a website, represented as ¼ rather than 1/4 for example? From what I've gathered, these are the only ones I can use: ½ ⅓ ⅔ ¼ ¾ Is this right and why is that? The reason why I ask this is because I've done a Google web search and can't seem to locate any others ... eg. 2/4 回答1: You can test http://www.mathjax.org/ it is a JavasScript library to make a Math Formula if this is what you want. 回答2: The image below displays all unicode-defined fraction

Using Fractions On Websites

喜欢而已 提交于 2020-01-09 12:02:05
问题 Is it possible to use any fraction symbol on a website, represented as ¼ rather than 1/4 for example? From what I've gathered, these are the only ones I can use: ½ ⅓ ⅔ ¼ ¾ Is this right and why is that? The reason why I ask this is because I've done a Google web search and can't seem to locate any others ... eg. 2/4 回答1: You can test http://www.mathjax.org/ it is a JavasScript library to make a Math Formula if this is what you want. 回答2: The image below displays all unicode-defined fraction

Format an Integer using Java String Format

与世无争的帅哥 提交于 2020-01-09 08:37:47
问题 I am wondering if it is possible, using the String.format method in Java, to give an integer preceding zeros? For example: 1 would become 001 2 would become 002 ... 11 would become 011 12 would become 012 ... 526 would remain as 526 ...etc At the moment I have tried the following code: String imageName = "_%3d" + "_%s"; for( int i = 0; i < 1000; i++ ){ System.out.println( String.format( imageName, i, "foo" ) ); } Unfortunately, this precedes the number with 3 empty spaces. Is it possible to

Using Struts2 Tags to Formatting Numbers

僤鯓⒐⒋嵵緔 提交于 2020-01-09 05:25:09
问题 I want to format some numbers in our jsp pages. first i define some resources in my porperties format.number.with2Decimal={0,number,#0.00} ...... Question1: i want to know what is the ‘#’ and '0' means? 0.00,#0.00,##.00,###0.00 who can tell me the differences between them? thanks! Question2: if i define a BigDecimal type in my action BigDecimal number1; Then my page should using a format to show this value, 1.if number1=null then show -NIL- 2.if number1=0 then show -NIL- 3.if number1>0 then

Converting input number to Mysql decimal

﹥>﹥吖頭↗ 提交于 2020-01-07 05:24:09
问题 I'm trying to store decimals taken from input in a Mysql decimal (10,2) row. But when I enter 37.50 in the input, Mysql only stores 37.00 It seems to disregard everything after the dot. How can I store decimals? this the input <input class='form-control formBlock' name='payrate' value='' step="0.01" type='number' placeholder="Pay Rate..." required> So far I tried float: $payrate=floatval($_POST['payrate']); 回答1: It's unclear what you are asking. (Was there a question? Or was all that just

Removing commas in 'live' input fields in jquery

泄露秘密 提交于 2020-01-07 00:56:36
问题 I have a series of input boxes in a table with some number of dynamically generated rows as such: <table id="someDataTable"> <tbody> <tr> <td >Some Title</td> <td >Units</td> <td >Val/Unit</td> <td >Value</td> </tr> <tr> <td><input type="text" size="30" /></td> <td><input type="text" size="14" class="units commas"/></td> <td><input type="text" size="14" class="value commas"/></td> <td><input type="text" size="14" readonly="readonly" class="autoTotal"/></td> </tr> ... </tbody> </table> Now, I

Export to Excel format: cell type “general” and number turn into scientific notation

有些话、适合烂在心里 提交于 2020-01-06 14:27:06
问题 I have created a Jrxml to generate an excel output. The textfield of data type "String" in iReport is displayed with cell format as 'General' in the generated excel output. When Number is greater than 12 digit it turns into scientific notation. eg 999999999869 turns to 1E+12 . I need cell format to be either 'text' or 'number'. I have tried with property <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/> But it is not working . Also tried with pattern="@" and