Results for “int”
Small, practical examples. Search by task or narrow things down below.
Build an object from key-value entries
TypeScript: Object.fromEntries converts an iterable of pairs into ordinary own properties.
TypeScript✓ Tested
Build text incrementally with StringBuilder
C#: Append fragments instead of repeatedly concatenating intermediate strings in a loop.
C#✓ Tested
Calculate a least common multiple using a GCD
C: Divide before multiplying to reduce the risk of intermediate overflow.
C✓ Tested
Calculate a two-dimensional vector length
C++: hypot avoids unnecessary intermediate overflow in the sum of squares.
C++✓ Tested
Calculate a value inside JSX
Calculate a value inside JSX with a small React component and explicit browser behavior.
React✓ Tested
Calculate derived state during rendering
Calculate derived state during rendering with a small React component and explicit browser behavior.
React✓ Tested
Calculate the number of required pages
Python: Use integer arithmetic to round a nonnegative count up to a positive page size.
Python✓ Tested
Calculate whole days between dates
Subtract Julian day values for date-only inputs.
julianday✓ Tested
Calculate with exact rational values
Python: Use Fraction for exact ratios rather than binary floating-point approximations.
Python✓ Tested
Cancel an asynchronous operation on unmount
Cancel an asynchronous operation on unmount with a small React component and explicit browser behavior.
React✓ Tested
Centralize state changes in a reducer
Centralize state changes in a reducer with a small React component and explicit browser behavior.
React✓ Tested
Change visual order without changing DOM order
CSS: Order changes flex painting positions while keyboard and reading order still follow the document.
CSS✓ Tested