-
Notifications
You must be signed in to change notification settings - Fork 37
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
[NARS1] [ksbhaskar] %HD should also work on hexadecimal numbers with a 0x or 0X prefix #45
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
; ; | ||
; Copyright 1987,2001 Sanchez Computer Associates, Inc. ; | ||
; Copyright 1987,2001 Sanchez Computer Associates, Inc. ; | ||
; ; | ||
; Copyright (c) 2017 YottaDB LLC. and/or its subsidiaries. ; | ||
; All rights reserved. ; | ||
; ; | ||
; This source code contains the intellectual property ; | ||
; of its copyright holder(s), and is made available ; | ||
|
@@ -11,13 +14,17 @@ | |
%HD ;GT.M %HD utility - hexadecimal to decimal conversion program | ||
;invoke at INT with %HD in hexadecimal to return %HD in decimal | ||
;invoke at FUNC as an extrinsic function | ||
;Note: works even if input hex number contains 0x or 0X prefix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in next commit. Please review that. |
||
;if you make heavy use of this routine, consider $ZCALL | ||
; | ||
s %HD=$$FUNC(%HD) | ||
q | ||
INT r !,"Hexidecimal: ",%HD s %HD=$$FUNC(%HD) | ||
q | ||
FUNC(h) | ||
n prefix | ||
set prefix=$zextract(h,1,2) | ||
set:(("0X"=prefix)!("0x"=prefix)) h=($zextract(h,3,99)) | ||
q:$tr(h,"E","e")<0 "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize this is not part of this change, but this seems like a strange and inefficient way to test whether the input is a decimal number less than zero. Why not just something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is most likely to avoid NUMOFLOW errors. See example below E vs e.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
n c,d,dg | ||
s d=0,h=$tr(h,"abcdef","ABCDEF") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of inserting lines 25 through 27, why not change line 30 to: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Will do. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a matter of esthetics, but the semi-colon box doesn't line up, at least on the Github review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is likely because I have replaced the end of the line with tabs (instead of spaces) and that is how all lines in the rest of the copyright notice are. I do see all lines aligned in the actual code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK