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

Let to_number infer the base #2439

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/include/souffle/utility/EvaluatorUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ A symbol2numeric(const std::string& src) {
if constexpr (std::is_same_v<RamFloat, A>) {
return RamFloatFromString(src);
} else if constexpr (std::is_same_v<RamSigned, A>) {
return RamSignedFromString(src);
return RamSignedFromString(src, nullptr, 0);
} else if constexpr (std::is_same_v<RamUnsigned, A>) {
return RamUnsignedFromString(src);
return RamUnsignedFromString(src, nullptr, 0);
} else {
static_assert(sizeof(A) == 0, "Invalid type specified for symbol2Numeric");
}
Expand Down
8 changes: 7 additions & 1 deletion tests/semantic/strconv/A.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
10
-10
-4
-48879
-51966
4
10
48879
51966
6 changes: 6 additions & 0 deletions tests/semantic/strconv/strconv.dl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

A(x) :- x=to_number("10").
A(x) :- x=to_number("-10").
A(x) :- x=to_number("0xcafe").
A(x) :- x=to_number("-0xcafe").
A(x) :- x=to_number("0xBEEF").
A(x) :- x=to_number("-0xBEEF").
A(x) :- x=to_number("0b100").
A(x) :- x=to_number("-0b100").

.output A

Expand Down
Loading