Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add to_base function #8122

Merged
merged 4 commits into from
Jul 20, 2023
Merged

add to_base function #8122

merged 4 commits into from
Jul 20, 2023

Conversation

Maxxen
Copy link
Member

@Maxxen Maxxen commented Jul 1, 2023

Follows the excel semantics, with the slight deviation that the optional ”min_length” parameter has an upper limit on 64 digits. This allows us to stack allocate the result string and still pad enough zeroes to fit an entire 64 bit int in base 2.

@carlopi
Copy link
Contributor

carlopi commented Jul 1, 2023

Cool, couple of notes:

  • using lower case letters seems somehow more usual, but I guess one can the lowering in another pass.
  • what's the semantic with negative numbers as input?

@Maxxen
Copy link
Member Author

Maxxen commented Jul 1, 2023

Google sheets uses uppercase, so thats what i testef with.

Good catch on negative bumbers, idk, ill check tomorrow

@github-actions github-actions bot marked this pull request as draft July 2, 2023 10:45
@Maxxen
Copy link
Member Author

Maxxen commented Jul 2, 2023

Excel doesn't allow negative input numbers, so I've changed the implementation so that we check for it as well and throw invalidinput when detected.

@Maxxen Maxxen marked this pull request as ready for review July 2, 2023 10:47
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! LGTM - some comments

src/core_functions/scalar/string/to_base.cpp Outdated Show resolved Hide resolved
src/core_functions/scalar/string/to_base.cpp Show resolved Hide resolved
src/core_functions/scalar/string/to_base.cpp Show resolved Hide resolved
@github-actions github-actions bot marked this pull request as draft July 17, 2023 13:47
@Maxxen Maxxen marked this pull request as ready for review July 17, 2023 13:47
@Mytherin Mytherin merged commit 49f21b8 into duckdb:master Jul 20, 2023
53 checks passed
@Mytherin
Copy link
Collaborator

Thanks!

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.

None yet

3 participants