• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

why signed numeric

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any reason why signed numerics are used?
Signed numeric:http://www.ucop.edu/irc/campus_specs/cgx/signed_num.html
Why use the last digit of a number to determine if a number is positive or negative?

Is there a story from previous Java version or programming problems that signed numerics was invented or used?

Thanks!
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chihwah li wrote:Is there any reason why signed numerics are used?
Signed numeric:http://www.ucop.edu/irc/campus_specs/cgx/signed_num.html
Why use the last digit of a number to determine if a number is positive or negative?

Is there a story from previous Java version or programming problems that signed numerics was invented or used?

Thanks!



For the same number of bytes, you can access bigger (positive) numbers, if you know for sure that you'll have positive numbers assigned to that variable.
 
Master Rancher
Posts: 3696
44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shashank, did you read the link chihwah li provided? I don't think your explanation applies to that format; you're thinking of something else.

chihwah li wrote:IIs there a story from previous Java version or programming problems that signed numerics was invented or used?


The spec you quoted seems to have nothing to do with Java. Well, you could implement it in Java, or any other language, but it's independent of Java. Personally I've never seen that format before, and it looks rather strange and unintuitive to me. Can you show us another page that links to it, which might give us a hint what it's used for?
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike --

I did a little Googling on this. It's apparently a COBOL thing. It's a way that signed numbers were stored on tape from COBOL. It seems like it was ad-hoc in nature; I don't think there was a standard format, but it's more of a concept with many implementations. Perhaps something you do when you're storing numbers as BCD rather than binary? Maybe it's older than one's complement? Can't be.
 
Mike Simmons
Master Rancher
Posts: 3696
44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heh. I almost said it looks like the sort of thing they'd do back in the save-a-byte-where-you-can days of COBOL. Though I think we could easily come up with more readable alternatives. I wonder if there's supposed to be a meaningful difference between 1234 and 123D? Oh well. Thanks for tracking down the info, EFH!
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ernest Friedman-Hill wrote:Hi Mike --

I did a little Googling on this. It's apparently a COBOL thing. It's a way that signed numbers were stored on tape from COBOL. It seems like it was ad-hoc in nature; I don't think there was a standard format, but it's more of a concept with many implementations. Perhaps something you do when you're storing numbers as BCD rather than binary? Maybe it's older than one's complement? Can't be.



It's a weird name they chose though "signed".
 
Mike Simmons
Master Rancher
Posts: 3696
44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so - that part is somewhat standard terminology in computer programming. A signed number can be either positive or negative, whereas an unsigned number can only be positive. It's just this particular way of representing signed numbers that's a bit... unusual.
 
chihwah li
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ask this because the word signed at this page: Look at the attached picture.
It's from the book "Head first - Java" by Kathy Sierra & Bert Bates

signed.jpg
[Thumbnail for signed.jpg]
 
Mike Simmons
Master Rancher
Posts: 3696
44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. Well, Head First is using the term "signed" in the same sense we were just talking about. It means that Java's byte, short, int, long, float and double can all be positive or negative. That's all it means. The "signed numerics" described in your other link can also be positive or negative. But there's no other connection, really. The format that other link discusses has nothing to do with Java or Head First.
 
please buy this thing and then I get a fat cut of the action:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic