Results for “length”
Small, practical examples. Search by task or narrow things down below.
Calculate a two-dimensional vector length
C++: hypot avoids unnecessary intermediate overflow in the sum of squares.
C++✓ Tested
Compute a two-dimensional vector length
C: hypot avoids unnecessary intermediate overflow compared with squaring both inputs directly.
C✓ Tested
Extract a substring by offset and length
Bash Scripts: Bash substring offsets start at zero for an ordinary string.
Bash Scripts✓ Tested
Find the length of a calendar month
C#: DaysInMonth applies the Gregorian leap-year rules.
C#✓ Tested
Group strings by their length
Java: Choose a TreeMap supplier when group keys must have deterministic order.
Java✓ Tested
Inspect a file length without reading it
C#: Use FileInfo.Length to retrieve a logical size in bytes.
C#✓ Tested
Limit typed text to a maximum length
HTML: Maxlength limits ordinary user editing without replacing server-side validation.
HTML✓ Tested
Measure a string length
Count bytes before the null terminator with C strlen.
C✓ Tested
Measure the byte length of UTF-8 text
C#: Character count and encoded byte count can differ for non-ASCII text.
C#✓ Tested
Measure the length of ordinary text
SQL: Use the engine’s text-length function; this ASCII example has no trailing spaces.
SQL✓ Tested
Measure the length of ordinary text
SQL Server: Use the engine’s text-length function; this ASCII example has no trailing spaces.
SQL Server✓ Tested
Measure the length of ordinary text
Postgres: Use the engine’s text-length function; this ASCII example has no trailing spaces.
Postgres✓ Tested