Skip to main content

Questions tagged [formatting]

For programs that are concerned with producing meaningful or clearer output. A typical example would be the transformation of a decimal into a particular currency format with the correct number of decimal places. (Note that code layout is always in scope for answers, so this tag is not used to indicate perceived issues with that).

Filter by
Sorted by
Tagged with
6 votes
3 answers
270 views

This question used to contain a mistake in the code, so I had to debug and reformat it. This is the correct version. Why I made it A friend and I wanted to make a lightweight browser, since our ...
Chip01's user avatar
  • 413
5 votes
5 answers
1k views

I was concatenating a lot of strings lately, usually the results of std::format: ...
dalle's user avatar
  • 309
4 votes
3 answers
1k views

When PHP converts a number to string (for printing it out, for example), sometimes it may convert it to scientific notation out of nowhere (0.000021 for example). Or the number can be already in a ...
Your Common Sense's user avatar
6 votes
2 answers
386 views

I want to create a system that marks up text with tags inserted into a stream. Each tag frames a part of the text, creating a tree-like structure, just as in classic markup languages (HTML, XML...). I ...
Jerome Demantke's user avatar
3 votes
1 answer
113 views

Problem Description Printing the result of adding two numpy arrays together is very ugly. Here we will use these numpy arrays as an example: ...
mikeLundquist's user avatar
4 votes
2 answers
169 views

I'm somewhat new to python and I'm creating a script that requests to a certain API and then uses the response to populate a ...
Aldimar J's user avatar
0 votes
1 answer
276 views

I have this piece of code that checks the input of a text box before I compute for my main logic. This looks like it should be refactored but I'm currently stumped how to do so. The only thing that ...
jumping_bear's user avatar
1 vote
2 answers
169 views

I need to take a user's name and format it 'lastName, firstName middleName'. If firstName and middleName are not present then the comma should not be included with lastName. Below is what I came up ...
Samuel's user avatar
  • 21
1 vote
1 answer
273 views

For educational purpose I am preprocessing multiple short texts containing the description of the symptoms of cars fault. The text is written by humans and is rich in misspelling, capital letters and ...
Andrea Ciufo's user avatar
2 votes
1 answer
151 views

I am fairly new to Rust and thought a good way to practice would be to write a multithreaded segmented Sieve of Eratosthenes. It performs ok (searches ten-billion numbers in about 11 seconds on my ...
knots427's user avatar
3 votes
2 answers
291 views

So far I have reached chapter 5 of the K&R Book, Edition 2 from which I have been learning C. I spent a few days thinking of a solution to this program. I wrote two or three versions of the same ...
jr.çhåvez__07's user avatar
3 votes
2 answers
325 views

For the following exercise (Chapter 4, Ex-4.6) of the Book (K&R 2nd Edition): Exercise 4-6. Add commands for handling variables. (It's easy to provide twenty-six variables with single-letter ...
jr.çhåvez__07's user avatar
7 votes
3 answers
1k views

I am trying to do a few exercises from the K&R book from the first chapter - exercise 1-19. I have to write a program "detab" which replaces tabs in the input with the proper number of ...
jr.çhåvez__07's user avatar
5 votes
1 answer
992 views

A c# format provider that formats a double into a string using engineering notation rules. If the value is outside of the defined notation symbols it will default ...
Nifim's user avatar
  • 197
3 votes
2 answers
122 views

Re - designing c-style input output [ btw I use printf() and scanf() in the core ] Reasons for redesigning it :- Needs 2 functions for input output [ namely ...
Pear's user avatar
  • 243
3 votes
1 answer
717 views

I am trying out Leetcode problem 68 and I need your help to asses the code. I am pretty new to this. Given an array of strings words and a width ...
Chintamani Chavan's user avatar
1 vote
1 answer
2k views

This function creates takes an int * buffer and creates a neatly formatted string (useful for printing the contents of an array). Is the code easy to follow? Is it ...
cgoates's user avatar
  • 185
3 votes
1 answer
1k views

I just solved this exercise from Think Python, 2nd edition: Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function ...
pedromartins's user avatar
8 votes
1 answer
182 views

I wrote a function that receives a number as an argument and returns a number (technically, a string) with a maximum of 3 numerals, no matter if there's a decimal separator or not, plus the adequate ...
Megaptera novaeangliae's user avatar
2 votes
4 answers
1k views

I wrote a function that takes an array of 10 integers (from 0 to 9) that returns a string of those numbers as a phone number. Example: ...
Konstantine's user avatar
19 votes
4 answers
4k views

I'm writing a minimal C runtime targeting an old 32-bit Windows XP machine as a personal project. The C runtime provided by compilers is quite bloated. I wouldn't mind some library bloats up to ...
xiver77's user avatar
  • 419
4 votes
0 answers
86 views

I have reworked the code from my previous (linked) post. For reference: I have a string which contains JSON-like object flattened (stringify()ed). I need to JSON-...
user3132457's user avatar
-2 votes
2 answers
158 views

I have the following code function x () { return a ? (b ? 'result2' : 'result1') : 'result1'; } Is there a better way to combine these two conditions into one?...
AngularDebutant's user avatar
0 votes
2 answers
135 views

I have this code that writes the initial configuration of a simulator I'm writing to stdout. args is an instance of type ...
SRSR333's user avatar
  • 103
4 votes
1 answer
600 views

I wired up a Gear Shift Indicator for my dad's car to display what gear it is currently in, and showing changes with animations (sliding up and down as appropriate, with a few bonus ones for fun at ...
Phrontistes's user avatar

1
2 3 4 5
12