From 4519740ea7198b5a79055ae43848689ac7770602 Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:16:34 -0600 Subject: [PATCH] vault backup: 2024-09-11 12:16:34 --- education/software development/ECE1400/C.md | 11 ++++++++++- .../ECE1400/Chapter 3 Exercises.md | 9 +++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/education/software development/ECE1400/C.md b/education/software development/ECE1400/C.md index 3c8f51f..8687542 100644 --- a/education/software development/ECE1400/C.md +++ b/education/software development/ECE1400/C.md @@ -30,4 +30,13 @@ A variable must be declared before it is assigned. | Specifier | Function | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | `%d` | Display an integer | -| `%f` | Display a float. Specify the number of places to round to by adding a decimal and a number, eg `%.2f` would round to two decimal places. | \ No newline at end of file +| `%f` | Display a float. Specify the number of places to round to by adding a decimal and a number, eg `%.2f` would round to two decimal places. | +For number formatting specifiers, the convention is as follows: +`%-a.bX` +`%`: Start of the formatting specifier +`-`: (optional) If included, justify value left in space. Otherwise, justify right in space +`a`: (optional) If included, the size of the field in characters. +`.`: Separator between `a` and `b`. Optional if `b` is not specified +`b`: The number of decimal places to round to +`X`: The type of format to use, and the end of the specifier. Use `d` for integer base 10 (decimal) representation, `f` for fixed point decimal, and `e` for exponential notation +# Standard library \ No newline at end of file diff --git a/education/software development/ECE1400/Chapter 3 Exercises.md b/education/software development/ECE1400/Chapter 3 Exercises.md index 474cbaa..a1031e5 100644 --- a/education/software development/ECE1400/Chapter 3 Exercises.md +++ b/education/software development/ECE1400/Chapter 3 Exercises.md @@ -8,12 +8,13 @@ d. `1e-06 ` ```c float x = 0.12345; // a -printf("%-8.1f", x); +printf("%-8.1e", x); // b -printf("%10.6f", x); +printf("%10.6e", x); // c printf("%8.3f", x); // d -printf("%-6.0g", x); +printf("%-6.0f", x); ``` -c. \ No newline at end of file + +# 3.