Discussion:
negative values
(too old to reply)
Ryan E Mitchell
2005-08-18 15:59:50 UTC
Permalink
For lab 3, the notes say that to exit from inputting data, the 'cmp'
command will recognize large values as negative, however I can't seem to
get that to work. I assume it's because i'm using 'getchar' and not
'getint' because 'getchar' only picks up the first character, but I the
program didn't seem to work if I used getint first and then getchar in
the subroutine.

Are there people out there using getint, or have any suggestions?

Thanks

Ryan
Binaebi Akah
2005-08-18 16:32:48 UTC
Permalink
Well, I don't think we can use getint because no matter what, the user
is inputting ascii values. So we can't really consider it as an actual
integer, can we? I'm trying something out right now, and if it works,
I'll try to give a hint. If not, I probably will be too busy screaming
at my computer to post a message saying it didn't work, because I'm also
having problems. Haha...

Binaebi
Post by Ryan E Mitchell
For lab 3, the notes say that to exit from inputting data, the 'cmp'
command will recognize large values as negative, however I can't seem to
get that to work. I assume it's because i'm using 'getchar' and not
'getint' because 'getchar' only picks up the first character, but I the
program didn't seem to work if I used getint first and then getchar in
the subroutine.
Are there people out there using getint, or have any suggestions?
Thanks
Ryan
Binaebi Akah
2005-08-18 17:22:06 UTC
Permalink
As I suspected, it was my hex_in subroutine that was messing me up. Make
sure your arithmetic is right. For example, I was subtracting and
,getting a 0x10 for a character 'A' and thought nothing of it. Because
in decimal, 10 = A. Obviously, I need to work on details and getting
more sleep. As soon as my hex_in was fixed, inputting 80000000 base 16
worked perfectly.

Binaebi
Post by Ryan E Mitchell
For lab 3, the notes say that to exit from inputting data, the 'cmp'
command will recognize large values as negative, however I can't seem to
get that to work. I assume it's because i'm using 'getchar' and not
'getint' because 'getchar' only picks up the first character, but I the
program didn't seem to work if I used getint first and then getchar in
the subroutine.
Are there people out there using getint, or have any suggestions?
Thanks
Ryan
Ryan E Mitchell
2005-08-18 18:23:31 UTC
Permalink
Ohhhhhhhh.

Thanks!

Ryan
Post by Binaebi Akah
As I suspected, it was my hex_in subroutine that was messing me up. Make
sure your arithmetic is right. For example, I was subtracting and
,getting a 0x10 for a character 'A' and thought nothing of it. Because
in decimal, 10 = A. Obviously, I need to work on details and getting
more sleep. As soon as my hex_in was fixed, inputting 80000000 base 16
worked perfectly.
Binaebi
Post by Ryan E Mitchell
For lab 3, the notes say that to exit from inputting data, the 'cmp'
command will recognize large values as negative, however I can't seem
to get that to work. I assume it's because i'm using 'getchar' and not
'getint' because 'getchar' only picks up the first character, but I
the program didn't seem to work if I used getint first and then
getchar in the subroutine.
Are there people out there using getint, or have any suggestions?
Thanks
Ryan
Loading...