All Questions
43 questions
0
votes
2
answers
86
views
How to format an array of numbers into a string in C#?
The method String.Format has the following overload:
public static string Format (string format, params object?[] args);
which I supposed was meant for formatting many args of the same type into a ...
0
votes
0
answers
82
views
printf("%d", x) alters value of %d when spaces are added to the formatted string? [duplicate]
Consider this very simple lines of code:
#include <stdio.h>
#include <stdlib.h>
typedef int board[8][8];
board * initBoard(void)
{
board * b = malloc(sizeof(board));
if (!b) { ...
0
votes
1
answer
33
views
Need to output a function That takes in strings and ints in python
The function in question is:
switch({source}, condition1, Condition Nth, value1, value Nth)
The Way I need to output it involves using 0 and 1s (True/False) and will look like this:
"switch([.]...
1
vote
3
answers
73
views
How to create a list of names, excluding missing values?
I have been the getting results:
Name: Hemingway, Ernest
Name: Madonna,
Name: , Voltaire
Name: ,
It seems as though the code is skipping all of my if and elif statements, I'm new to this so any help ...
-3
votes
2
answers
317
views
How to format integers in Python?
I have the numbers:
'115000000000'
'10000000'
'99700000000'
I need to make them look like this:
'1150,00000000'
'0,10000000'
'997,00000000'
or
'1150'
'0,1'
'997'
0
votes
2
answers
134
views
Java printf: How define/declare empty spaces through a Conversion implicitly?
In Java having the following
printf("%-5s Hello %s %n", "", "There!")
It prints
Hello There!
Where exists 5 empty spaces located to the left.
Until here it works ...
2
votes
1
answer
1k
views
Custom string interpolation in Python
I want to create a custom f-string. For example, a CPT interpolator that always converts things it formats to capital letters:
a = "World"
normal_f_string = f"Hello {a}" # "Hello World"
...
0
votes
0
answers
50
views
Creating a string from a list of words so that the string is 25 characters long
Have a string:
s = "Now is the time for all good men to come to the aid of their country. Time is of the essence friends."
I want to divide s into substrings 25 characters in length like this:
"Now ...
-1
votes
2
answers
69
views
PHP Strip Zeros From String of Numbers
Currently, I have a SKU that is a string that is LS181004. I want to convert that string to just 18104. However, I am having problems with strings that have a 1010 in it as it gets reduced to 11 and I ...
8
votes
6
answers
31k
views
How to get last 2 digits of year from Javascript date [duplicate]
I have string in the following format "30.11.2019". I need to transform it into a Date and get the short year representation (last 2 digits from year) like "19".
The following code doesn't work
var ...
0
votes
2
answers
445
views
How to make string f-string after variable initiazation? [duplicate]
Let's suppose I get some string and set it to variable - it can't be created as f-string:
str1 = 'date time for {val1} and {val2}'
Then variables inside the string initialized:
val1 = 1
val2 = 77
...
-1
votes
1
answer
1k
views
Swift. How to set custom number format? With space thouthand separator and two digits after point
I need separate thouthands with space, and two digit after point.
let d1: Double = 20000000.0
let d2: Double = 1.2345
I want to view:
let s1 = String(format: "????", d1) //20 000 000.00
let s2 = ...
-1
votes
2
answers
320
views
Can String.format remove numbers if they are zero?
I am building a stopwatch and I want to only display a field for the hours if they are >0.
At the moment I solve it like this, is there a shorter way?
String timeLeftFormatted = "";
if (hours >...
3
votes
1
answer
382
views
Combining C# String.Format format options
I'd like to format my number as a percent value with an always visible sign.
To format it as a percent value I can do:
string.Format("{0:P2}", 1.45);
For visible signs I'll do:
string.Format("{0:+#....
1
vote
3
answers
1k
views
Message box formatting
I need my totals to be in currency format. my code is not letting me output a long sting into a message box. below is what i am trying to output into a message box. how can i format my totals to come ...