Skip to content

Add FLOOR function#747

Merged
MarkMpn merged 3 commits into
MarkMpn:masterfrom
sulimanbenhalim:add-floor-function
Mar 17, 2026
Merged

Add FLOOR function#747
MarkMpn merged 3 commits into
MarkMpn:masterfrom
sulimanbenhalim:add-floor-function

Conversation

@sulimanbenhalim

Copy link
Copy Markdown
Contributor

Adds the FLOOR function which returns the largest integer less than or equal to the specified numeric expression.

Changes

  • ExpressionFunctions.cs — six overloads covering all supported numeric types: int, bigint, decimal, float, money, real
  • FunctionMetadata.cs — autocomplete/IntelliSense entry
  • ExpressionFunctionTests.cs — unit tests covering positive, negative, fractional, whole, and null inputs

Usage

SELECT FLOOR(4.9)   -- 4
SELECT FLOOR(-4.1)  -- -5
SELECT FLOOR(5.0)   -- 5

@MarkMpn

MarkMpn commented Mar 11, 2026

Copy link
Copy Markdown
Owner

Thanks for this and the other related functions, that's great!

I just want to check how the precision and scale of decimal values flow through this to ensure there aren't any surprises in subsequent calculations, I'll try to take a look into this over the next week or so.

@sulimanbenhalim

Copy link
Copy Markdown
Contributor Author

Rebased all three PRs with proper overloads and extended DecimalPrecisionAttribute with an optional scale parameter to handle CEILING/FLOOR returning decimal(p, 0).

@sonarqubecloud

Copy link
Copy Markdown

@MarkMpn MarkMpn merged commit 2ef94ff into MarkMpn:master Mar 17, 2026
2 checks passed
@sulimanbenhalim sulimanbenhalim deleted the add-floor-function branch March 17, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants