Converting between binary and decimal representations of IEEE 754 floating-point numbers in C++, Java and Python

This post implements a previous post that explains how to convert 32-bit floating point numbers to binary numbers in the IEEE 754 format. What we have is some C++ / Java / Python routines that will allows us to convert a floating point value into it’s equivalent binary counterpart, using the standard IEEE 754 representation consisting of the sign bit, exponent and mantissa (fractional part).
Continue reading

Polymorphism in Java

An example:

import java.util.*;

public class JavaPolymorph 
{
    public void Print()
    { System.out.println( "JavaPolymorph"); }  
    
   public static void main(String[] args)
   {
      JavaPolymorph j1 = new JavaPolymorph(); 
      JavaPolymorph j2 = new SubJavaPolymorph();
      
      j1.Print();
      j2.Print();       
   }
}

public class SubJavaPolymorph extends JavaPolymorph
{
    public void Print()
    { System.out.println( "SubJavaPolymorph"); }    
}

Continue reading

Mathematical Expression Parsers in Java and C++

Basic Expression Parsing

Click here for advanced expression parsing

When writing your own calculator it is necessary to build a converter that can transform an input mathematical expression such as ( 1 + 8 ) – ( ( 3 * 4 ) / 2 ), into a format that is more suited for evaluation by computers.
Continue reading

Java Strings: The Basics

One long section of code outlining how to achieve some basic string handling objectives in Java. Currently trying to get to grips with this language after spending far too many years concentrating on C++. Each technique is demonstrated with a code snippet. As with a lot of my other stuff, any new stuff I find useful will get added at a later date:
Continue reading