The Artima Developer Community
Sponsored Link

Java Answers Forum
4 byte ASCII encoding

1 reply on 1 page. Most recent reply: Jul 18, 2003 1:04 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
chandra

Posts: 1
Nickname: chandrab92
Registered: Jul, 2003

4 byte ASCII encoding Posted: Jul 17, 2003 5:57 AM
Reply to this message Reply
Advertisement
I have an integer sequence counter whose values can range between 0 to 2174000000. This sequence counter needs to be converted into 4 byte ascii encoded format for further processing.. Hence , pls let me know how this can be done ..

Thanks in advance,

Chandra


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: 4 byte ASCII encoding Posted: Jul 18, 2003 1:04 PM
Reply to this message Reply
It cannot be done. You are about 4 bits short.

American Standard Code for Information Interchange (ASCII) is a standard coding of 7-bit numeric codes to characters.

2^(7*4) = 2^28 = 0x10000000 = 268435456 decimal, which is much less than 2174000000 (or 0x81949B80 in hex), so you are out of luck. In other words, to get the range you want, you'll need all 32 bits.

Or maybe I misinterpreted your question? Maybe you mean something else by "4 byte ascii encoded format"? Maybe you just want to encode it as base64 or something like that?

Flat View: This topic has 1 reply on 1 page
Topic: JTree node selection  small problem Previous Topic   Next Topic Topic: jscrollpane

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use