number-formatting

Is it possible to show numbers in non-engineering format in MATLAB?

谁都会走 提交于 2019-11-26 23:37:59
问题 I have some large floating point numbers such as 1243564832.75 in MATLAB. MATLAB changes the format to 1.2435e09 or if I use long format: 1.2435648e09 or something like that. Is there any way I can display the numbers in their non-engineering format ( 1243564832.75 )? 回答1: Call the following command format longG Then the display should be "fixed" 来源: https://stackoverflow.com/questions/3999205/is-it-possible-to-show-numbers-in-non-engineering-format-in-matlab

JTable cell editor number format

☆樱花仙子☆ 提交于 2019-11-26 23:16:23
问题 I need to show numbers in jTable with exact 2 decimal places. To accomplish this I have created a custom cell editor as: public class NumberCellEditor extends DefaultCellEditor { public NumberCellEditor(){ super(new JFormattedTextField()); } public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { JFormattedTextField editor = (JFormattedTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column); if (value!

Suppress exponential formatting in figure ticks

丶灬走出姿态 提交于 2019-11-26 22:45:45
Tick labels for ticks bigger than about 10'000, get formatted to 1x10^4 for example. Whereas the exponential part appears above the corresponding axes. This misbehavior has been well described on on matlab central as well, but without a solution. Thanks for your help. The 'quick trick' set(gca, 'YTickLabel',get(gca,'YTick')) did not work when applied to bar3, as can be seen on the following figure. One way to get better control over tick labels, and to avoid the exponential formatting, is to use TICK2TEXT from the File Exchange. Here's an example: y = cool(7); %# define some data ah = axes; %#

Java : JFormattedTextField saving numbers

有些话、适合烂在心里 提交于 2019-11-26 21:07:00
In my application I want to input numbers (amounts) to a specific limit, and hence have used JFormattedTextField. Limit like "12345678.99" i.e. 8 digits before "." and 2 after "." or so on. This is my implementation code, but it doesn't result as expected. startBalTxt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("########.##")))); startBalTxt.setText(resourceMap.getString("startBalTxt.text")); // NOI18N startBalTxt.setFont(Utility.getTextFont()); startBalTxt.setName("startBalTxt"); // NOI18N INPUT RESULT

f:convertNumber remove comma as thousand separator [duplicate]

≡放荡痞女 提交于 2019-11-26 21:04:38
问题 This question already has an answer here : Set decimal separator when using f:convertNumber (1 answer) Closed 4 years ago . I want to round value with four decimal places to one decimal place. That is why I use f:convertNumber : <h:outputText value="${current.dayAverage.pressureRelative}" > <f:convertNumber maxFractionDigits="1"/> </h:outputText> The rounding is done right, but the f:convertNumber adds thousand comma separator. I want to remove this separator but I don't know how. I am using

How to prefix a positive number with plus sign in PHP

送分小仙女□ 提交于 2019-11-26 20:55:47
问题 I need to design a function to return negative numbers unchanged but should add a + sign at the start of the number if its already no present. Example: Input Output ---------------- +1 +1 1 +1 -1 -1 It will get only numeric input. function formatNum($num) { # something here..perhaps a regex? } This function is going to be called several times in echo/print so the quicker the better. Update: Thank you all for the answers. I must tell the sprintf based solution is really fast. 回答1: You can use

Decimal separator in NumberFormat

删除回忆录丶 提交于 2019-11-26 20:44:42
Given a locale java.text.NumberFormat: NumberFormat numberFormat = NumberFormat.getInstance(); How can I get the character used as Decimal separator (if it's a comma or a point) in that numberformat? How can I modify this property without having to use new DecimalFormat(format)? Thanks The helper class DecimalFomatSymbols is what you are looking for: DecimalFormat format=DecimalFormat.getInstance(); DecimalFormatSymbols symbols=format.getDecimalFormatSymbols(); char sep=symbols.getDecimalSeparator(); To set you symbols as needed: //create a new instance DecimalFormatSymbols custom=new

JQuery Number Formatting

試著忘記壹切 提交于 2019-11-26 20:20:28
There are way too many questions and answers about this basic functionality, I cannot see the wood for the trees. In Java there is only one simple answer ( java.text.NumberFormat and its subclasses) so I'm sure the majority of plugins, questions and answers will mature eventually to a de-facto standard for JQuery. This plugin is the best I found so far, but I don't know if it's still developed, is mature etc. http://plugins.jquery.com/project/numberformatter Is there a better solution? Is it mature / active enough to rely on? Edit: I would like to be able to format currencies, decimal,

In jQuery, what's the best way of formatting a number to 2 decimal places?

夙愿已清 提交于 2019-11-26 19:44:54
This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function? If you're doing this to several fields, or doing it quite often, then perhaps a plugin is the answer. Here's the beginnings of a jQuery plugin that formats the value of a field to two decimal places. It is triggered by the onchange event of the field. You may want something different. <script type="text/javascript"> // mini jQuery plugin that formats to

How to read in numbers with a comma as decimal separator?

馋奶兔 提交于 2019-11-26 18:53:54
I have a series of CSV files where numbers are formatted in the european style using commas instead of decimal points, i.e. 0,5 instead of 0.5 . There are too many of these files to edit them before importing to R. I was hoping there is an easy parameter for the read.csv() function, or a method to apply to the extracted dataset in order for R to treat the data as a number rather than a string. When you check ?read.table you will probably find all the answer that you need. There are two issues with (continental) European csv files: What does the c in csv stand for? For standard csv this is a ,