Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit 9272255

Browse files
authored
Merge branch 'main' into size
2 parents 8b53ebb + d2da492 commit 9272255

54 files changed

Lines changed: 4341 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/concept-of-the-week.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
content/uiux/concepts/convergent-thinking/convergent-thinking.md
1+
content/swift/concepts/ranges/ranges.md

content/c-sharp/concepts/arrays/arrays.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,21 @@ type[] arrayName;
2424
// Create the array variable and initialize it with an array of N items:
2525
type[] arrayName = new type[N];
2626
27+
// Classic Syntax
28+
2729
// Create the array variable and initialize it by specifying the contents:
2830
type[] arrayName = new type[] { value1, value2, value3, ... valueN };
2931
3032
// Alternative way of creating the array and specifying the contents:
3133
type[] arrayName = { value1, value2, value3, ... valueN };
34+
35+
// Collection Expression Syntax (C# 12+)
36+
37+
// Create an empty array:
38+
type[] arrayName = [];
39+
40+
// Create the array variable and initialize it by specifying the contents:
41+
type[] arrayName = [ value1, value2, value3, ... valueN ];
3242
```
3343

3444
> **Note:** Arrays in C# have a set size, meaning the number of elements they hold cannot be changed once the array has been created.
@@ -44,8 +54,8 @@ public class Example
4454
{
4555
public static void Main(string[] args)
4656
{
47-
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
48-
// indexes: 0 1 2 3 4
57+
char[] vowels = [ 'a', 'e', 'i', 'o', 'u' ];
58+
// indexes: 0 1 2 3 4
4959
5060
Console.WriteLine(vowels[0]); // Output: a
5161
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
Title: 'Asinh()'
3+
Description: 'Returns the inverse hyperbolic sine of a number, in radians.'
4+
Subjects:
5+
- 'Code Foundations'
6+
- 'Computer Science'
7+
Tags:
8+
- 'Arithmetic'
9+
- 'Methods'
10+
- 'Numbers'
11+
CatalogContent:
12+
- 'learn-c-sharp'
13+
- 'paths/computer-science'
14+
---
15+
16+
The **`Math.Asinh()`** [method](https://www.codecademy.com/resources/docs/c-sharp/methods) returns the inverse hyperbolic sine of a number, in radians. This method appears frequently in advanced mathematics, including physics, geometry, machine learning, and numerical analysis.
17+
18+
> **Note:** The static method `Math.Asinh()` was introduced in .NET Core 2.1.
19+
20+
## Syntax
21+
22+
```pseudo
23+
Math.Asinh(value);
24+
```
25+
26+
**Parameters:**
27+
28+
- `value` (double): A real number. If value is `NaN`, the method returns `NaN`.
29+
30+
**Return value:**
31+
32+
Returns the inverse hyperbolic sine of `value`, in radians.
33+
34+
## Example
35+
36+
The following example demonstrates the `Math.Asinh()` method and writes the result to the console:
37+
38+
```cs
39+
using System;
40+
class Program
41+
{
42+
static void Main()
43+
{
44+
double x = 2;
45+
double result = Math.Asinh(x);
46+
Console.WriteLine(result);
47+
}
48+
}
49+
```
50+
51+
The example will result in the following output:
52+
53+
```shell
54+
1.4436354751788103
55+
```
56+
57+
## Codebyte Example
58+
59+
The following codebyte example uses the `Math.PI` constant field to convert the result into degrees:
60+
61+
```codebyte/csharp
62+
using System;
63+
class Program
64+
{
65+
static void Main()
66+
{
67+
double x = 4;
68+
double radians = Math.Asinh(x);
69+
double degrees = radians * (180 / Math.PI);
70+
71+
Console.WriteLine($"Radians: {radians}");
72+
Console.WriteLine($"Degrees: {degrees}");
73+
}
74+
}
75+
```
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
Title: 'Log10()'
3+
Description: 'Returns the base-10 logarithm of a specified number.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Web Development'
7+
Tags:
8+
- 'Arithmetic'
9+
- 'Functions'
10+
- 'Math'
11+
- 'Methods'
12+
CatalogContent:
13+
- 'learn-c-sharp'
14+
- 'paths/computer-science'
15+
---
16+
17+
In C#, the **`Math.Log10()`** [method](https://www.codecademy.com/resources/docs/c-sharp/methods) calculates the base-10 logarithm of a given number. This logarithm represents the power to which 10 must be raised to obtain the input value. The method is defined in the `System` namespace.
18+
19+
## Syntax
20+
21+
```pseudo
22+
Math.Log10(number);
23+
```
24+
25+
**Parameters:**
26+
27+
- `number`: A `double` value whose base-10 logarithm is computed.
28+
29+
**Return value:**
30+
31+
Returns a `double` that represents the base-10 logarithm of `number`.
32+
33+
Return values for different inputs:
34+
35+
- If the input is a positive number, the method returns its base-10 logarithm.
36+
- If the input is `0`, the method returns `NegativeInfinity`.
37+
- If the input is a negative number, the method returns `NaN`.
38+
- If the input is `NaN`, the method returns `NaN`.
39+
- If the input is `PositiveInfinity`, the method returns `PositiveInfinity`.
40+
- If the input is `NegativeInfinity`, the method returns `NaN`.
41+
42+
## Example
43+
44+
The example below demonstrates the return values of `Math.Log10()` for different inputs:
45+
46+
```cs
47+
using System;
48+
49+
class Geeks {
50+
public static void Main(String[] args) {
51+
double a = 4.55;
52+
double b = 0;
53+
double c = -2.45;
54+
double nan = Double.NaN;
55+
double positiveInfinity = Double.PositiveInfinity;
56+
double negativeInfinity = Double.NegativeInfinity;
57+
58+
Console.WriteLine(Math.Log10(a));
59+
Console.WriteLine(Math.Log10(b));
60+
Console.WriteLine(Math.Log10(c));
61+
Console.WriteLine(Math.Log10(nan));
62+
Console.WriteLine(Math.Log10(positiveInfinity));
63+
Console.WriteLine(Math.Log10(negativeInfinity));
64+
}
65+
}
66+
```
67+
68+
The output of the code is:
69+
70+
```shell
71+
0.658011396657112
72+
-Infinity
73+
NaN
74+
NaN
75+
Infinity
76+
NaN
77+
```
78+
79+
## Codebyte Example
80+
81+
This codebyte example calculates the base-10 logarithm of a given number and prints the result:
82+
83+
```codebyte/csharp
84+
using System;
85+
86+
class Program {
87+
static void Main() {
88+
double x = 10.0;
89+
double result = Math.Log10(x);
90+
91+
Console.WriteLine($"The base-10 logarithm of {x} is {result}");
92+
}
93+
}
94+
```
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
Title: 'fpclassify()'
3+
Description: 'Classifies a floating-point value into categories such as zero, normal, subnormal, infinite, or NaN.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Data Science'
7+
Tags:
8+
- 'Classification'
9+
- 'Functions'
10+
- 'Math'
11+
CatalogContent:
12+
- 'learn-c-plus-plus'
13+
- 'paths/computer-science'
14+
---
15+
16+
The **`fpclassify()`** [function](https://www.codecademy.com/resources/docs/cpp/functions) in C++ returns an integer value indicating the classification of a floating-point number. It categorizes values as normal, subnormal, zero, infinite, or NaN (Not-a-Number). The function is available through the `<cmath>` header.
17+
18+
## Syntax
19+
20+
```pseudo
21+
fpclassify(x)
22+
```
23+
24+
**Parameters:**
25+
26+
- `x`: A floating-point value (can be `float`, `double`, or `long double`).
27+
28+
**Return value:**
29+
30+
The `fpclassify()` function returns one of the following integer constants:
31+
32+
- `FP_INFINITE`: The value is positive or negative infinity.
33+
- `FP_NAN`: The value is NaN (Not-a-Number).
34+
- `FP_ZERO`: The value is zero.
35+
- `FP_SUBNORMAL`: The value is a subnormal (denormalized) number.
36+
- `FP_NORMAL`: The value is a normal finite non-zero number.
37+
38+
## Example
39+
40+
The following example demonstrates various classifications using `fpclassify()`:
41+
42+
```cpp
43+
#include <iostream>
44+
#include <cmath>
45+
46+
using namespace std;
47+
48+
int main() {
49+
double normal = 1.5;
50+
double zero = 0.0;
51+
double inf = INFINITY;
52+
double nan = NAN;
53+
54+
cout << "Classification of " << normal << ": ";
55+
if (fpclassify(normal) == FP_NORMAL) {
56+
cout << "Normal" << endl;
57+
}
58+
59+
cout << "Classification of " << zero << ": ";
60+
if (fpclassify(zero) == FP_ZERO) {
61+
cout << "Zero" << endl;
62+
}
63+
64+
cout << "Classification of inf: ";
65+
if (fpclassify(inf) == FP_INFINITE) {
66+
cout << "Infinite" << endl;
67+
}
68+
69+
cout << "Classification of nan: ";
70+
if (fpclassify(nan) == FP_NAN) {
71+
cout << "NaN" << endl;
72+
}
73+
74+
return 0;
75+
}
76+
```
77+
78+
The output of this code is:
79+
80+
```shell
81+
Classification of 1.5: Normal
82+
Classification of 0: Zero
83+
Classification of inf: Infinite
84+
Classification of nan: NaN
85+
```
86+
87+
## Codebyte Example
88+
89+
The following runnable example shows how to use `fpclassify()` with different values:
90+
91+
```codebyte/cpp
92+
#include <iostream>
93+
#include <cmath>
94+
95+
using namespace std;
96+
97+
int main() {
98+
double values[] = {1.0, 0.0, INFINITY, NAN, -5.5};
99+
100+
for (double val : values) {
101+
cout << "fpclassify(" << val << ") = ";
102+
103+
switch(fpclassify(val)) {
104+
case FP_INFINITE:
105+
cout << "Infinite";
106+
break;
107+
case FP_NAN:
108+
cout << "NaN";
109+
break;
110+
case FP_ZERO:
111+
cout << "Zero";
112+
break;
113+
case FP_SUBNORMAL:
114+
cout << "Subnormal";
115+
break;
116+
case FP_NORMAL:
117+
cout << "Normal";
118+
break;
119+
}
120+
cout << endl;
121+
}
122+
123+
return 0;
124+
}
125+
```

0 commit comments

Comments
 (0)