Skip to content

Commit

Permalink
FIXED: Issue#475: xinteger//1: missing cut and inconsistent handling
Browse files Browse the repository at this point in the history
of negative integers over the two modes.
  • Loading branch information
Jan Wielemaker authored and keriharris committed Jun 18, 2019
1 parent 2e5ab87 commit 8243e4c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions library/dcg/basics.pl
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,22 @@
%
% Generate or extract an integer from a sequence of hexadecimal
% digits. Hexadecimal characters include both uppercase (A-F) and
% lowercase (a-f) letters.
% lowercase (a-f) letters. The value may be preceeded by a sign
% (+/-)

xinteger(Val, Head, Tail) :-
integer(Val),
integer(Val), !,
format(codes(Head, Tail), '~16r', [Val]).
xinteger(Val) -->
sign(C), !,
xdigit(D0),
xdigits(D),
{ mkval([D0|D], 16, Val0),
( C == 0'-
-> Val is -Val0
; Val = Val0
)
}.
xinteger(Val) -->
xdigit(D0),
xdigits(D),
Expand Down

0 comments on commit 8243e4c

Please sign in to comment.