format

what is the printf in C# [duplicate]

只谈情不闲聊 提交于 2019-12-30 08:01:06
问题 This question already has answers here : sprintf in C#? (3 answers) Closed 4 years ago . I want to know what to use in C# to format my output in my console window I tried to use \t but it did not work I know there is printf in C to format my output check this image https://s15.postimg.cc/94fstpi2z/Console.png 回答1: There is no direct "printf" duplication in C#. You can use PInvoke to call it from a C library. However there is Console.WriteLine("args1: {0} args2: {1}", value1, value2); Or

Swift 2.0 Format 1000's into a friendly K's

血红的双手。 提交于 2019-12-30 05:59:26
问题 I'm trying to write a function to present thousands and millions into K's and M's For instance: 1000 = 1k 1100 = 1.1k 15000 = 15k 115000 = 115k 1000000 = 1m Here is where I got so far: func formatPoints(num: Int) -> String { let newNum = String(num / 1000) var newNumString = "\(num)" if num > 1000 && num < 1000000 { newNumString = "\(newNum)k" } else if num > 1000000 { newNumString = "\(newNum)m" } return newNumString } formatPoints(51100) // THIS RETURNS 51K instead of 51.1K How do I get

Swift 2.0 Format 1000's into a friendly K's

断了今生、忘了曾经 提交于 2019-12-30 05:58:02
问题 I'm trying to write a function to present thousands and millions into K's and M's For instance: 1000 = 1k 1100 = 1.1k 15000 = 15k 115000 = 115k 1000000 = 1m Here is where I got so far: func formatPoints(num: Int) -> String { let newNum = String(num / 1000) var newNumString = "\(num)" if num > 1000 && num < 1000000 { newNumString = "\(newNum)k" } else if num > 1000000 { newNumString = "\(newNum)m" } return newNumString } formatPoints(51100) // THIS RETURNS 51K instead of 51.1K How do I get

Parse DICOM files in native Python

て烟熏妆下的殇ゞ 提交于 2019-12-30 00:54:46
问题 What is the simplest and most-pythonic way to parse a DICOM file? A native Python implementation without the use of non-Python libraries would be much preferred. DICOM is the standard file format in digital medical imaging (look here for more information). There are some C/C++ libraries that support reading (a subset) of DICOM files. Two or three of them even have Python bindings. A native Python parser would serve two purposes for me: No need to build any external C/C++ libraries. Learn

column replacement with awk, with retaining the format

爷,独闯天下 提交于 2019-12-29 09:59:50
问题 I have a a.pdb file as, ATOM 1 N ARG 1 0.000 0.000 0.000 1.00 0.00 N ATOM 2 H1 ARG 1 0.000 0.000 0.000 1.00 0.00 H ATOM 3 H2 ARG 1 0.000 0.000 0.000 1.00 0.00 H ATOM 4 H3 ARG 1 0.000 0.000 0.000 1.00 0.00 H and a.xyz file as 16.388 -5.760 -23.332 17.226 -5.608 -23.768 15.760 -5.238 -23.831 17.921 -5.926 -26.697 I want to replace 6,7 and 8th column of a.pdb with a.xyz. Once replaced, I need to maintain tabs/space/columns of a.pdb. I have tried awk 'NR==FNR {fld1[NR]=$1; fld2[NR]=$2; fld3[NR]=

Reading Mifare Classic returns strange characters

流过昼夜 提交于 2019-12-29 09:19:06
问题 When reading a MIFARE card with Android and converting the data to UTF-8 I get strange characters like �. I'm trying to build an application that can read some kind of ID card we're using. The problem now is that I get weird characters between words and some words are split between blocks so how can I safely get a word I'm looking for? For instance my readings is something like this: 43224���19032019�� at block 2 sektor 2 bindex :8 and with splitting where rest of the number starting with 19

Prevent round off in String.format(“%.2f”, doubleValue) in Java

限于喜欢 提交于 2019-12-29 06:45:34
问题 How do I prevent String.format("%.2f", doubleValue); from rounding off (round half up algorithm) instead of just truncating it? e.g. doubleValue = 123.459 after formatting, doubleValue = 123.46 I just want to discard the last digit, 123.45 I know there are other ways to do this, I just want to know if this is possible using the String.format. 回答1: You can always set the rounding mode: http://java.sun.com/javase/6/docs/api/java/math/RoundingMode.html and then use String.Format() HALF_EVEN is

How to convert a week number to a date in Javascript

谁说我不能喝 提交于 2019-12-29 06:18:38
问题 I had tried to find some work done but I haven't had luck. Any ideas? Examples: Week, 1, 2001 => 2001-01-01 Week, 26, 2007 => 2007-06-01 回答1: As Kevin's code does not implement ISO 8601 properly (first day of the first week of year must be a Monday), I've corrected it and ended up with (also check it on jsfiddle): function firstDayOfWeek(week, year) { if (year==null) { year = (new Date()).getFullYear(); } var date = firstWeekOfYear(year), weekTime = weeksToMilliseconds(week), targetTime =

PHP date(): minutes without leading zeros

给你一囗甜甜゛ 提交于 2019-12-29 03:33:06
问题 I'd like to know if there is a formatting letter for PHP's date() that allows me to print minutes without leading zeros, or whether I have to manually test for and remove leading zeros? 回答1: Use: $minutes = intval(date('i')); 回答2: For times with more information than just minutes: ltrim() - Strip whitespace (or other characters) from the beginning of a string ltrim(date('i:s'), 0); returns: 8:24 回答3: According to the PHP Documentation, the date() function does not have a placeholder for

Formatting the output of arrays, into a column

丶灬走出姿态 提交于 2019-12-29 02:08:10
问题 I just needed some assistance on formatting the output into a specific fashion. I satisfied all the requirements of the assignment, except the output. I apologize for the bad format of this post, any suggestions and help is greatly appreciated. I need the output to look like: Mr. Random - $500 Mr. BobRandom - $250 etc-8 more times (sum total of all dollars) Heres my code: import javax.swing.JOptionPane; import java.util.Arrays; public class PeerTutors { public static void main(String[] args)