number-formatting

jq reformatting decimals in scientific notation — can this be avoided?

ぐ巨炮叔叔 提交于 2019-12-01 02:04:47
问题 I found difference between json-data created by JavaScipt and via jq with bash (and other programming languages). With JavaScript I can create decimal numbers with up to six digits after the point, even when I use float() . But with jq its different, because adding a decimal value takes four digits after the decimal point only. My problem is that I need decimal numbers to store in SQL, with up to six digits after the point. Example: $ JSON='{"decimal":0.00001}' $ echo "$JSON" | jq . {

Format a number to display a comma when larger than a thousand

倾然丶 夕夏残阳落幕 提交于 2019-11-30 23:51:24
问题 I am writing some code in Visual Basic.net and have a question. If I have a long number, that is larger than 1000, how can I format this value to be 1,000 (with a comma) and for this to be stored in a string? For e.g. 1234 will be stored as 1,234 12345 will be stored as 12,345 123456 will be stored as 123,456 Is this done with a TryParse statement? May I have some help to so this? 回答1: Take a look at The Numeric ("N") Format Specifier General use: Dim dblValue As Double = -12445.6789 Console

Defining cross-platform money_format function (Linux and Windows)

﹥>﹥吖頭↗ 提交于 2019-11-30 20:24:00
I have read that money_format is not available on windows, and on some Linux distributions (i.e. BSD 4.11 variants). But I want to write cross-platform library using normal function, when available and using this workaround when not, so my library will be able to run on every PHP-based web server. Is there any simple solution to check whether built-in function is available and if not to include the solution from above? The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows. So you can use this

How to always show two decimal places on a number in PL/SQL

痞子三分冷 提交于 2019-11-30 19:31:50
问题 Folks, I have a existing stored procedure that I'm trying to update to always show two decimal places even when it's a whole number or single decimal number. This stored procedure builds out a message that has to show v_credit_amt as a two decimal number, yet the value assigned to v_credit_amt can be either a whole number or single decimal or a two decimal value i.e. 175 should display as 175.00, 250.5 should display as 250.50, 395.95 should display as 395.95. Here is the relevant stock pl

Force leading zero in number input

怎甘沉沦 提交于 2019-11-30 18:45:26
I'm writing an alarm web app. I have two number inputs, one for the hours, one for the minutes. Thus, when I use my keyboard arrows, they go from 0 to 23/59. Is there an HTML native way to make them go from 00 (01,02, et.) to 23/59 instead ? I'm only worried about the UI aspects as my JS manages the missing 0 anyway. EDIT - As requested : What I have : What I want : Instead of going from 0,1,2 to 59, I'd like to automatically have a leading 0 when the number is smaller than 10 (00,01,02 to 59). I'm afraid there is not native HTML way to do that unless using a Select tag. If you are using a

Objective-C: format numbers to ordinals: 1, 2, 3, .. to 1st, 2nd, 3rd

大兔子大兔子 提交于 2019-11-30 16:32:04
问题 In Objective C, is there any way to format an integer to ordinals 1 => "1st", 2 => "2nd" etc... that works for any language ? So if the user is French he will see "1er", "2ieme" etc.. Thanks a lot! Edit : This is for an iOs app 回答1: Have you taken a look at TTTOrdinalNumberFormatter which is in FormatterKit? It works great, and I'm pretty sure it's exactly what you're looking for. Here's an example taken from the kit: TTTOrdinalNumberFormatter *ordinalNumberFormatter = [

How to get format numbers with decimals (XCode)

亡梦爱人 提交于 2019-11-30 16:30:09
My objective is to create a customer calculator application for iPhone and I am using Xcode to write my application. My problem, that I cannot find a solution for, is how to format a number that uses decimals (with extra zeros) without switching into scientific notation I tried... buttonScreen.text = [NSString stringWithFormat:@"%0.f",currentNumber]; %0.f formatting always rounds so if the user types in "4.23" it displays "4" %f formats numbers with 6 decimals (typing in '5' displays as '5.000000'), but I don't want to show extra zeros on the end of the number. %10.4f is something else that I

How to get format numbers with decimals (XCode)

好久不见. 提交于 2019-11-30 16:14:21
问题 My objective is to create a customer calculator application for iPhone and I am using Xcode to write my application. My problem, that I cannot find a solution for, is how to format a number that uses decimals (with extra zeros) without switching into scientific notation I tried... buttonScreen.text = [NSString stringWithFormat:@"%0.f",currentNumber]; %0.f formatting always rounds so if the user types in "4.23" it displays "4" %f formats numbers with 6 decimals (typing in '5' displays as '5

Add comma to numbers every three digits in datatable (R)

老子叫甜甜 提交于 2019-11-30 14:03:32
Suppose my data looks like this: df1 = data.frame(A=c(1000000.51,5000.33), B=c(0.565,0.794)) I want to use DataTables and have column A be (1,000,001 ; 5,000) library(DT) datatable(df1) %>% formatPercentage('B', 2) %>% formatRound('A',digits = 0) I know i can use scales library(scales) comma_format()(1000000) but I'm not sure how to combine that with DataTables Thanks! Had this same issue: Try This: require(DT) require(dplyr) df1 = data.frame(A=c(1000000.51,5000.33, 2500, 251), B=c(0.565,0.794, .685, .456)) df1 <- df1 %>% mutate(A=round(A,digits=0)) datatable(df1) %>% formatPercentage('B', 2)

NumberFormat text field without commas

不羁的心 提交于 2019-11-30 13:50:02
I have a JFormattedTextField which I want to accept numbers in the 5 digit range. The following code works correctly: myNumberBox = new JFormattedTextField(NumberFormat.getIntegerInstance()); However, when I type "12345" into the field and switch focus, a comma is inserted due to my locale, making the text "12,345". How can I prevent commas from being added to my input? Better yet, can they be stripped out even if the user does insert commas? You have to disable the grouping in your NumberFormat object like this: NumberFormat format = NumberFormat.getIntegerInstance(); format.setGroupingUsed