format

How to format floating point value with fix number of digits?

扶醉桌前 提交于 2020-01-30 13:02:47
问题 Is it possible in C# to format a double value with double.ToString in a way that I have always a fixed number of digits, no matter on which side of the decimal point? Say I wish 6 digits, I want to have these results: 0.00123456789 gives "0.00123" 1.23456789 gives "1.23457" 123.456789 gives "123.457" 0.0000000123456789 gives "0.00000" 12345678.9 gives "12345679" (on overflow I want to see all digits left of decimalpoint) 4.2 gives "4.20000" I'm experimenting with double.ToString, but cannot

(GCC) Dollar sign in printf format string

我只是一个虾纸丫 提交于 2020-01-28 05:12:26
问题 I've seen the following line in a source code written in C: printf("%2$d %1$d", a, b); What does it mean? 回答1: It's an extension to the language added by POSIX (C11-compliant behaviour should be as described in an answer by @chux). Notation %2$d means the same as %d (output signed integer), except it formats the parameter with given 1-based number (in your case it's a second parameter, b ). So, when you run the following code: #include <stdio.h> int main() { int a = 3, b = 2; printf("%2$d %1

(GCC) Dollar sign in printf format string

隐身守侯 提交于 2020-01-28 05:12:09
问题 I've seen the following line in a source code written in C: printf("%2$d %1$d", a, b); What does it mean? 回答1: It's an extension to the language added by POSIX (C11-compliant behaviour should be as described in an answer by @chux). Notation %2$d means the same as %d (output signed integer), except it formats the parameter with given 1-based number (in your case it's a second parameter, b ). So, when you run the following code: #include <stdio.h> int main() { int a = 3, b = 2; printf("%2$d %1

How to get Delphi Currency Type to Round like Excel all the time?

为君一笑 提交于 2020-01-28 04:20:47
问题 I'm trying to get Delphi to Round like Excel but I can't. Here is the code: procedure TForm1.Button1Click(Sender: TObject); var s : string; c : currency; begin c := 54321.245; s := ''; s := s + Format('Variable: %m',[c]); s := s + chr(13); s := s + Format(' Literal: %m',[54321.245]); ShowMessage(s); end; I'm using a currency variable that is set to 54321.245 and when I format this variable it rounds using Bankers Rounding. However, when I format the same value as a literal it rounds the way

In node.js how to get/construct URL string from WHATWG URL including user and password but nothing after host

空扰寡人 提交于 2020-01-26 04:05:27
问题 What would be the recommended way of deriving the following: https://user:pass@hostname:port From: https://user:pass@hostname:port/p/a/t/h?q=whatevere#hash when dealing with node.js url module using current WHATWG URL ? 回答1: Pretty sure you can use standard javascript with node.js var s = 'https://user:pass@hostname:port/path#hash'; s = s.substring(0, s.lastIndexOf('/')); That should give you s as the value you want. Caz Update - You could also do this if you can't predict the number of / in

Numbered Lists not working using PHP, CKEditor and Outlook

感情迁移 提交于 2020-01-25 21:01:31
问题 When i write a text using CKEditor in my application and format it as a numbered list it is displayed correct like Answers to your questions: 1. First Answer 2. Second Answer and the html behind is <p><span style="color:#1f497d">Answers to your questions:</span></p> <ol> <li><span style="color:#1f497d">First Answer</span></li> <li><span style="color:#1f497d">Second Answer</span></li> </ol> but when I send this text in an email outlook ( my current Version is 2016) is not showing the numbers

Numbered Lists not working using PHP, CKEditor and Outlook

夙愿已清 提交于 2020-01-25 21:01:14
问题 When i write a text using CKEditor in my application and format it as a numbered list it is displayed correct like Answers to your questions: 1. First Answer 2. Second Answer and the html behind is <p><span style="color:#1f497d">Answers to your questions:</span></p> <ol> <li><span style="color:#1f497d">First Answer</span></li> <li><span style="color:#1f497d">Second Answer</span></li> </ol> but when I send this text in an email outlook ( my current Version is 2016) is not showing the numbers

Change date format on a template

↘锁芯ラ 提交于 2020-01-25 20:45:28
问题 I'm using the Foundry template on Squarespace and I need to change the date format on post pages from english to portuguese. Instead of "May 6" I need "6 Mai". In Brazil we use the pattern dd/mm/yyyy. In this case I just want the day and month, and also translate all the months (to: Jan, Fev, Mar, Abr, Mai, Jun, Jul, Ago, Set, Out, Nov, Dez). I already saw people solving this for others languages there. But not to portuguese or on the Foundry template. It's possible to make a code-injection

Why isn't my Perl format working?

夙愿已清 提交于 2020-01-25 09:01:46
问题 All, I'm trying to get the code at the bottom to look like a check. Could you help me troubleshoot? Thanks, Frank format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>>>>>>>>>>>>>>>>> $chkno $chkno $first $last $addr[0] $addr[1] $phone $date Pay to the Order of: $payee $amount For: $memo Stamped Signature nova> perl proj3_3.pl Use of comma-less variable list is deprecated at proj3_3.pl line 48. Name "main::date" used only once: possible typo at proj3_3.pl line 24. Name "main::last"

Passing data from a Pandas Dataframe into a String using the string.format() Method

为君一笑 提交于 2020-01-25 08:59:48
问题 I have a dataframe which includes names, age and score. What I'm trying to do is pass the name, age and score into a message (a string) using the format() method. Code: import pandas as pd df = pd.read_csv('data.csv') df A B C 0 Matt 23 0.98 1 Mark 34 9.33 2 Luke 52 2.54 3 John 67 4.73 The message I want to pass this data into: message = "{} is {} years old and has a score of {}" My limited understanding of using the .format() method with the message (string) message.format() From what I can