Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Binary Display Formatter

Posted on 2001-06-21
7
Medium Priority
?
224 Views
Last Modified: 2010-03-31
I would like to be able to display a binary string in the following format:

8 bits:

0000 0000

16 bits

0000 0000 0000 0000

32 bits

0000 0000 0000 0000 0000 0000 0000 0000

Yet when I grab the string, i want to eliminate the space.

Can I perform this task without haveing to tokenize the string to read it every time i want the data.

It there away to build a display formatter...but for the display only..not having to manupulate my original string??

Thanks
0
Comment
Question by:Vernstump
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6217198
public class BinaryDisplay {
  public static void disply(String binary) {
    int l = binary.length();
    if((l % 8 != 0) && (l % 16 != 0) && (l % 32 != 0)) {
      System.out.println("Incorect format.");
      return;
    }
    System.out.print("Binary : ");
    while(binary.length() != 0) {
      System.out.print(binary.substring(0, 4) + " ");
      binary = binary.substring(4);
    }
    System.out.println("");
  }
  public static void main(String[] args) {
    BinaryDisplay.disply("11110000");
    BinaryDisplay.disply("1111000011110000");
    BinaryDisplay.disply("11110000111100001111000011110000");
  }
}
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6217230
public class BinaryDisplay {
  public static void disply(String binary) {
    int l = binary.length();
    if((l % 8 != 0) && (l % 16 != 0) && (l % 32 != 0)) {
      System.out.println("Incorect format.");
      return;
    }
    System.out.print("Binary : ");
    while(binary.length() != 0) {
      System.out.print(binary.substring(0, 4) + " ");
      binary = binary.substring(4);
    }
    System.out.println("");
  }
  public static void main(String[] args) {
    BinaryDisplay.disply("11110000");
    BinaryDisplay.disply("1111000011110000");
    BinaryDisplay.disply("11110000111100001111000011110000");
  }
}
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6217292
public class BinaryDisplay {
  public static void disply(String binary) {
    int l = binary.length();
    if((l % 8 != 0) && (l % 16 != 0) && (l % 32 != 0)) {
      System.out.println("Incorect format.");
      return;
    }
    System.out.print("Binary : ");
    while(binary.length() != 0) {
      System.out.print(binary.substring(0, 4) + " ");
      binary = binary.substring(4);
    }
    System.out.println("");
  }
  public static void main(String[] args) {
    BinaryDisplay.disply("11110000");
    BinaryDisplay.disply("1111000011110000");
    BinaryDisplay.disply("11110000111100001111000011110000");
  }
}
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:Ovi
ID: 6217310
public class BinaryDisplay {
  public static void disply(String binary) {
    int l = binary.length();
    if((l % 8 != 0) && (l % 16 != 0) && (l % 32 != 0)) {
      System.out.println("Incorect format.");
      return;
    }
    System.out.print("Binary : ");
    while(binary.length() != 0) {
      System.out.print(binary.substring(0, 4) + " ");
      binary = binary.substring(4);
    }
    System.out.println("");
  }
  public static void main(String[] args) {
    BinaryDisplay.disply("11110000");
    BinaryDisplay.disply("1111000011110000");
    BinaryDisplay.disply("11110000111100001111000011110000");
  }
}
0
 

Author Comment

by:Vernstump
ID: 6229827
I dont want to alter the string itself!!

Example:

1111 1111...shoudl be displayed however when the user trys to edit this field....he.she will not be allowed to edit the space between number groups.

0
 
LVL 5

Expert Comment

by:vemul
ID: 7621035
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- To be PAQ'ed and points refunded
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7643119
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question