Convert float to Float lost precision?

Hi all,
float r = 3.456789012f;
Float R = new Float(r);
System.out.println (R.toString());
float y = R.floatValue();
System.out.println(y);
gives 3.4567890 in both cases.
Is the precision being truncated when changing from float to Float?
any help please to ensure all precision can be maintained?
thanks
andrew

Is the precision being truncated when changing from
float to Float?
Nope. Try System.out.println(r).
any help please to ensure all precision can be
maintained?
Nope. The float data type can't handle that much precision. You can use double to get a bit better precision, and the java.math.BigDecimal class to get arbitrary precision.

Similar Messages

  • Convert float to rational

    Hello,
    The TIFF tag header protocol requires a data type I am not really conversant with, the Rational Data type: http://en.wikipedia.org/wiki/Rational_data_type
    I need to convert double precision numbers to this data type, e.g. 24.5 needs to be a ratio of two integers: {49,2}. Is there an existing LabVIEW algorithm to perform this operation? All my NI searches keep resulting in Rational ClearCase or Rational Array interpolation. I seem to have found a lot of the theory behind this: http://stackoverflow.com/questions/95727/how-to-convert-floats-to-human-readable-fractions
    But, is this implemented in labVIEW already, or should I implement the above-referenced c-code?
    Thanks,
    Mello
    Data Science Automation
    CTA, CLA, CPI
    SHAZAM!
    Solved!
    Go to Solution.

    I was curious if there were other ways to do this and found that Scilab combined with the LabVIEW Gateway works quite well. The 'rat' function is available in Scilab; Scilab and the LabVIEW gateway were both easy to install...
    http://www.scilab.org/products/other/labview_gateway
    Message Edited by Phillip Brooks on 03-04-2010 08:29 AM
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    scilab_rat.JPG ‏46 KB

  • Arithmetic Overflow error converting float to data type numeric

    Hi,
    Am facing strange issue,I have function which returns money datatype and assigning the return money value to float datatype in table.
    Error msg:
    Msg 8115, Level 16, State 6, Procedure GBCalcCatalogPriceNewV2, Line 204
    Arithmetic overflow error converting float to data type numeric.
    The statement has been terminated.
    Strange thing is the same stored procedure is working fine in production environment,but in the deveopment i see this error.Am scared if the same happens in the production environment.Please advice and advance
    thanks
    Regards
    RAj

    Strange thing is the same stored procedure is working fine in production environment,
    How could that be strange? This is an error that occurs depending on the data. Accidents that are waiting to happen will happen sooner or later.
    Then again, a development database may be more prone to such errors, because data that entered are completely out of whack with real life data. Still it is a warning sign. If you have some place where you convert data from float to numeric, you must consider
    the risk that the float value is outside the range for the numeric data type. How do you prevent that from happening? Maybe a CHECK constraint on the column? Of if the data origins from a money column, use a numeric data type with sufficient precision.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Function module to convert float value to data type 'dec'

    Hi experts,
      In a report i need to convert float value to the data type 'DEC'. How to convert it. Is there any function module for this conversion.
    Thanks and Regards,
    Vaibhav Tiwari.

    Hi ..
    We can do like this...
    Data : V_float type F value '12345.67'.
    Data: V_dec type P Decimals 2.
    Write:/ V_float exponent 0. "This will display it like Type P
    or
    Write V_float to V_dec EXPONENT 0.
    Write:/ V_dec.
    reward if Helpful.
    <b></b>

  • Convert float to 4 bytes array

    How can I convert float type to 4 byte array -
    not with strings but to exact binary representation.

    See the javadoc of Float.floatToIntBits. Converting an int to an array of 4 bytes is easy, so I will left it as an exercise.
    floatToIntBits
    public static int floatToIntBits(float value)Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.
    Bit 31 (the bit that is selected by the mask 0x80000000) represents the sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask 0x7f800000) represent the exponent. Bits 22-0 (the bits that are selected by the mask 0x007fffff) represent the significand (sometimes called the mantissa) of the floating-point number.
    If the argument is positive infinity, the result is 0x7f800000.
    If the argument is negative infinity, the result is 0xff800000.
    If the argument is NaN, the result is 0x7fc00000.
    In all cases, the result is an integer that, when given to the intBitsToFloat(int) method, will produce a floating-point value the same as the argument to floatToIntBits (except all NaN values are collapsed to a single "canonical" NaN value).
    Parameters:
    value - a floating-point number.
    Returns:
    the bits that represent the floating-point number.

  • Converting float array to Float array

    Hi, is there any efficent way to convert float[][] to Float[][] without iterating the array and creating Float object for each float data? I have a method performing calculations based on a 2D array( float[][]) and then need to store the result in a TreeMap data structure. The "put" method for TreeMap ask Object type.
    Thanks in advance!

    1) No
    2) An array of float is an object as well:
    Object obj = new float[]{1.0, 2.0, 3.0};3) What you want to store? If your structure is somewhat like this:
    float[][] f = {
       { 1.0, 2.0, 3.0 },
       { 4.0, 5.0, 6.0 },
    };and you want to "index" your TreeMap by the first element of each row of your float[] array, you could do something like this:
        SortedMap sm = new TreeMap();
        sm.put(new Float(f[0][0]), f[0]); // Arrays are objects as well
        sm.put(new Float(f[1][0]), f[1]); //and so on.

  • Convert float to Float

    Hi,
    How can I convert float to Float?
    thanks
    andrew

    I got the answer myself, Float Q = new Float(q);

  • Convert float to integer

    how to convert float to integer?
    and convert it back from integer to float?

    You can cast a float to an integer using the following syntax:
    float f = 1.245;
    int i = (int)f;
    To convert an int to a float you use a similar syntax:
    int i = 3;
    float f = (float)i;
    You'll also find some interesting methods for the Float and Integer object s in the Java API documentation.

  • How can I convert Float numbers which are represented as 'E-05' to full precision

    I have over 6,000 records which all have 'E-05' in the field.
    It should actually be full precision, such as:  0.000046793055472781
    How can I convert all of these?  There are around 600,000 records in the whole table, so I only want to convert the 'E-05' records.  For some reason these are incorrect, but all the others are totally fine.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    If they are float values, they have the full precision you can get with a float value.
    Keep in mind that what you see in management studio is a textual representation of the value. It is not the value itself. A float value is stored as 53 bits of mantissa and an 11-bit exponent which is a power of 2.
    To view the value without the exponent, you can cast to decimal, although this will give you a slightly different value. You can also use the str function:
    DECLARE @f float
    SELECT @f = 0.000046793055472781
    SELECT str(@f, 20, 18)
    However, formatting of the value is best done in the presentation layer. You should not change the data you have in the table. But if the source is actually exact decimal values, maybe you should use a decimal data type instead.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Converting float to binary

    Hi,
    I was wondering if anyone knew of a way to convert a float value (as ascii) to a binary value?
    I need a program that will take in a number of floating values from a file, convert the values to binary and then write out these values in another file, 4 bytes at a time.
    I know that you can convert decimals to binary with an easy function but i've searched for float to binary and came up with nothing.
    any help would be really appreciated,
    cheers!

    One of the Java's problems is that you can easily get lost in the sea of Javadocs...
    java.io.DataOutputStream
    writeFloat(float v)
    Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.
    java.io.DataInputStream
    readFloat
    public float readFloat()
    throws IOException
    Reads four input bytes and returns a float value. It does this by first constructing an int value in exactly the manner of the readInt method, then converting this int value to a float in exactly the manner of the method Float.intBitsToFloat. This method is suitable for reading bytes written by the writeFloat method of interface DataOutput.

  • Convert Float to Char

    Hi,
    I'm having problem when converting a float variable to char - it seems like the float value is automatically rounded into the char variable, but I don't want that.
    Does anybody know a wafunction or a way of avoiding this convertion round?
    Thanks,
    Nuno Afonso

    With the input parameters you gave me...
    Error in ASSIGN: Memory protection error
    The current program "SAPLSCFL " uses the ASSIGN statement. 
    However, the offset of the segment (536) plus the length (1)
    is greater than the length of the segment (536).           
    This is not allowed.                                       

  • Error trying to convert float to expanded form for a check application

    I am writing a program to generate a check, but when it tries to parse the Float (netpay) into a String in expanded form (e.g. 1.23 becomes 1 dollar and twenty-three cents) it throws weird arrayOutOfBounds exceptions
    * Check.java
    * Created on January 23, 2008, 9:55 AM
    package payrollapplication;
    public class Check extends javax.swing.JFrame {
    public Employee emp;
    String expanded;
    /** Creates new form Check */
    boolean debug = true;
    public Check() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    date = new javax.swing.JLabel();
    jPanel1 = new javax.swing.JPanel();
    name = new javax.swing.JLabel();
    amtexpanded = new javax.swing.JLabel();
    amtnum = new javax.swing.JLabel();
    empid = new javax.swing.JLabel();
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("EMP Name Here");
    setAlwaysOnTop(true);
    setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
    setResizable(false);
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowActivated(java.awt.event.WindowEvent evt) {
    formWindowActivated(evt);
    date.setText("DATE");
    jPanel1.setBackground(new java.awt.Color(102, 102, 0));
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 429, Short.MAX_VALUE)
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 62, Short.MAX_VALUE)
    name.setText("NAME");
    amtexpanded.setText("AMT EXPANDED");
    amtnum.setText("AMT #");
    empid.setText("EMPID");
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(10, 10, 10)
    .addComponent(amtexpanded, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE))
    .addComponent(name, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(amtnum, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(date, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
    .addComponent(empid, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
    .addContainerGap())
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(14, 14, 14)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(date)
    .addComponent(name))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(amtnum)
    .addComponent(amtexpanded, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(empid)
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    pack();
    }// </editor-fold>
    private void formWindowActivated(java.awt.event.WindowEvent evt) {                                    
    initDisplay(); //Computes the expanded form of the number and fills the windows with information
    amtexpanded.setText(expanded);
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Check().setVisible(true);
    public void initDisplay() {
    try {
    amtnum.setText("$"+emp.netpay); //Fill in the net pay
    name.setText(""+emp.fname+" "+emp.mname+" "+emp.lname+" "+emp.suffix); //Fill in the name
    System.out.println("NOT YET IMPLEMENTED");
    expanded = "";
    //begin to compute the expanded form
    //determine the length of the left side of the decimal
    expanded = emp.netpay+"";
    String[] split = expanded.split(".");
    int length = split[0].length();
    //Now we compute the first half of the number
    int wholeLength = split[0].length();
    char[] arr = split[0].toCharArray(); //create the character array
    expanded = ""; //Clear it
    if(length == 3) {
    System.out.println("Length of 3, working...");
    //Assume we are starting at the one thousands
    //Since 0 is 1, we need to test for 3 for 1,000s not 4
    switch(arr[3]) {
    case '1': expanded = "One Thousand ";
    case '2': expanded = "Two Thousand ";
    case '3': expanded = "Three Thousand ";
    case '4': expanded = "Four Thousand ";
    case '5': expanded = "Five Thousand ";
    case '6': expanded = "Six Thousand ";
    case '7': expanded = "Seven Thousand ";
    case '8': expanded = "Eight Thousand ";
    case '9': expanded = "Nine Thousand ";
    switch(arr[2]) {
    case '1': expanded = expanded + "One-Hundred ";
    case '2': expanded = expanded + "Two-Hundred ";
    case '3': expanded = expanded + "Three-Hundred ";
    case '4': expanded = expanded + "Four-Hundred ";
    case '5': expanded = expanded + "Five-Hundred ";
    case '6': expanded = expanded + "Six-Hundred ";
    case '7': expanded = expanded + "Seven-Hundred ";
    case '8': expanded = expanded + "Eight-Hundred ";
    case '9': expanded = expanded + "Nine-Hundred ";
    switch(arr[1]) {
    case '0': {
    switch(arr[0]) {
    case '0': expanded = expanded + "";
    case '1': expanded = expanded + "and One";
    case '2': expanded = expanded + "and Two";
    case '3': expanded = expanded + "and Three";
    case '4': expanded = expanded + "and Four";
    case '5': expanded = expanded + "and Five";
    case '6': expanded = expanded + "and Six";
    case '7': expanded = expanded + "and Seven";
    case '8': expanded = expanded + "and Eight";
    case '9': expanded = expanded + "and Nine";
    case '1': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Ten";
    case '1': expanded = expanded + "and Eleven";
    case '2': expanded = expanded + "and Twelve";
    case '3': expanded = expanded + "and Thirteen";
    case '4': expanded = expanded + "and Fourteen";
    case '5': expanded = expanded + "and Fifteen";
    case '6': expanded = expanded + "and Sixteen";
    case '7': expanded = expanded + "and Seventeen";
    case '8': expanded = expanded + "and Eighteen";
    case '9': expanded = expanded + "and Nineteen";
    case '2': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Twenty";
    case '1': expanded = expanded + "and Twenty-One";
    case '2': expanded = expanded + "and Twenty-Two";
    case '3': expanded = expanded + "and Twenty-Three";
    case '4': expanded = expanded + "and Twenty-Four";
    case '5': expanded = expanded + "and Twenty-Five";
    case '6': expanded = expanded + "and Twenty-Six";
    case '7': expanded = expanded + "and Twenty-Seven";
    case '8': expanded = expanded + "and Twenty-Eight";
    case '9': expanded = expanded + "and Twenty-Nine";
    case'3': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Thirty";
    case '1': expanded = expanded + "and Thirty-One";
    case '2': expanded = expanded + "and Thirty-Two";
    case '3': expanded = expanded + "and Thirty-Three";
    case '4': expanded = expanded + "and Thirty-Four";
    case '5': expanded = expanded + "and Thirty-Five";
    case '6': expanded = expanded + "and Thirty-Six";
    case '7': expanded = expanded + "and Thirty-Seven";
    case '8': expanded = expanded + "and Thirty-Eight";
    case '9': expanded = expanded + "and Thirty-Nine";
    case '4': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Fourty";
    case '1': expanded = expanded + "and Fourty-One";
    case '2': expanded = expanded + "and Fourty-Two";
    case '3': expanded = expanded + "and Fourty-Three";
    case '4': expanded = expanded + "and Fourty-Four";
    case '5': expanded = expanded + "and Fourty-Five";
    case '6': expanded = expanded + "and Fourty-Six";
    case '7': expanded = expanded + "and Fourty-Seven";
    case '8': expanded = expanded + "and Fourty-Eight";
    case '9': expanded = expanded + "and Fourty-Nine";
    case '5': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Fifty";
    case '1': expanded = expanded + "and Fifty-One";
    case '2': expanded = expanded + "and Fifty-Two";
    case '3': expanded = expanded + "and Fifty-Three";
    case '4': expanded = expanded + "and Fifty-Four";
    case '5': expanded = expanded + "and Fifty-Five";
    case '6': expanded = expanded + "and Fifty-Six";
    case '7': expanded = expanded + "and Fifty-Seven";
    case '8': expanded = expanded + "and Fifty-Eight";
    case '9': expanded = expanded + "and Fifty-Nine";
    case '6': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Sixty";
    case '1': expanded = expanded + "and Sixty-One";
    case '2': expanded = expanded + "and Sixty-Two";
    case '3': expanded = expanded + "and Sixty-Three";
    case '4': expanded = expanded + "and Sixty-Four";
    case '5': expanded = expanded + "and Sixty-Five";
    case '6': expanded = expanded + "and Sixty-Six";
    case '7': expanded = expanded + "and Sixty-Seven";
    case '8': expanded = expanded + "and Sixty-Eight";
    case '9': expanded = expanded + "and Sixty-Nine";
    case '7': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Seventy";
    case '1': expanded = expanded + "and Seventy-One";
    case '2': expanded = expanded + "and Seventy-Two";
    case '3': expanded = expanded + "and Seventy-Three";
    case '4': expanded = expanded + "and Seventy-Four";
    case '5': expanded = expanded + "and Seventy-Five";
    case '6': expanded = expanded + "and Seventy-Six";
    case '7': expanded = expanded + "and Seventy-Seven";
    case '8': expanded = expanded + "and Seventy-Eight";
    case '9': expanded = expanded + "and Seventy-Nine";
    case '8': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Eighty";
    case '1': expanded = expanded + "and Eighty-One";
    case '2': expanded = expanded + "and Eighty-Two";
    case '3': expanded = expanded + "and Eighty-Three";
    case '4': expanded = expanded + "and Eighty-Four";
    case '5': expanded = expanded + "and Eighty-Five";
    case '6': expanded = expanded + "and Eighty-Six";
    case '7': expanded = expanded + "and Eigthy-Seven";
    case '8': expanded = expanded + "and Eighty-Eight";
    case '9': expanded = expanded + "and Eighty-Nine";
    case '9': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Ninety";
    case '1': expanded = expanded + "and Ninety-One";
    case '2': expanded = expanded + "and Ninety-Two";
    case '3': expanded = expanded + "and Ninety-Three";
    case '4': expanded = expanded + "and Ninety-Four";
    case '5': expanded = expanded + "and Ninety-Five";
    case '6': expanded = expanded + "and Ninety-Six";
    case '7': expanded = expanded + "and Ninety-Seven";
    case '8': expanded = expanded + "and Ninety-Eight";
    case '9': expanded = expanded + "and Ninety-Nine";
    //Now we move down the length, 2, 1 ,
    if(length == 2) {
    System.out.println("length of 2, working...");
    switch(arr[2]) {
    case '1': expanded = expanded + "One-Hundred ";
    case '2': expanded = expanded + "Two-Hundred ";
    case '3': expanded = expanded + "Three-Hundred ";
    case '4': expanded = expanded + "Four-Hundred ";
    case '5': expanded = expanded + "Five-Hundred ";
    case '6': expanded = expanded + "Six-Hundred ";
    case '7': expanded = expanded + "Seven-Hundred ";
    case '8': expanded = expanded + "Eight-Hundred ";
    case '9': expanded = expanded + "Nine-Hundred ";
    switch(arr[1]) {
    case '0': {
    switch(arr[0]) {
    case '0': expanded = expanded + "";
    case '1': expanded = expanded + "and One";
    case '2': expanded = expanded + "and Two";
    case '3': expanded = expanded + "and Three";
    case '4': expanded = expanded + "and Four";
    case '5': expanded = expanded + "and Five";
    case '6': expanded = expanded + "and Six";
    case '7': expanded = expanded + "and Seven";
    case '8': expanded = expanded + "and Eight";
    case '9': expanded = expanded + "and Nine";
    case '1': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Ten";
    case '1': expanded = expanded + "and Eleven";
    case '2': expanded = expanded + "and Twelve";
    case '3': expanded = expanded + "and Thirteen";
    case '4': expanded = expanded + "and Fourteen";
    case '5': expanded = expanded + "and Fifteen";
    case '6': expanded = expanded + "and Sixteen";
    case '7': expanded = expanded + "and Seventeen";
    case '8': expanded = expanded + "and Eighteen";
    case '9': expanded = expanded + "and Nineteen";
    case '2': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Twenty";
    case '1': expanded = expanded + "and Twenty-One";
    case '2': expanded = expanded + "and Twenty-Two";
    case '3': expanded = expanded + "and Twenty-Three";
    case '4': expanded = expanded + "and Twenty-Four";
    case '5': expanded = expanded + "and Twenty-Five";
    case '6': expanded = expanded + "and Twenty-Six";
    case '7': expanded = expanded + "and Twenty-Seven";
    case '8': expanded = expanded + "and Twenty-Eight";
    case '9': expanded = expanded + "and Twenty-Nine";
    case'3': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Thirty";
    case '1': expanded = expanded + "and Thirty-One";
    case '2': expanded = expanded + "and Thirty-Two";
    case '3': expanded = expanded + "and Thirty-Three";
    case '4': expanded = expanded + "and Thirty-Four";
    case '5': expanded = expanded + "and Thirty-Five";
    case '6': expanded = expanded + "and Thirty-Six";
    case '7': expanded = expanded + "and Thirty-Seven";
    case '8': expanded = expanded + "and Thirty-Eight";
    case '9': expanded = expanded + "and Thirty-Nine";
    case '4': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Fourty";
    case '1': expanded = expanded + "and Fourty-One";
    case '2': expanded = expanded + "and Fourty-Two";
    case '3': expanded = expanded + "and Fourty-Three";
    case '4': expanded = expanded + "and Fourty-Four";
    case '5': expanded = expanded + "and Fourty-Five";
    case '6': expanded = expanded + "and Fourty-Six";
    case '7': expanded = expanded + "and Fourty-Seven";
    case '8': expanded = expanded + "and Fourty-Eight";
    case '9': expanded = expanded + "and Fourty-Nine";
    case '5': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Fifty";
    case '1': expanded = expanded + "and Fifty-One";
    case '2': expanded = expanded + "and Fifty-Two";
    case '3': expanded = expanded + "and Fifty-Three";
    case '4': expanded = expanded + "and Fifty-Four";
    case '5': expanded = expanded + "and Fifty-Five";
    case '6': expanded = expanded + "and Fifty-Six";
    case '7': expanded = expanded + "and Fifty-Seven";
    case '8': expanded = expanded + "and Fifty-Eight";
    case '9': expanded = expanded + "and Fifty-Nine";
    case '6': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Sixty";
    case '1': expanded = expanded + "and Sixty-One";
    case '2': expanded = expanded + "and Sixty-Two";
    case '3': expanded = expanded + "and Sixty-Three";
    case '4': expanded = expanded + "and Sixty-Four";
    case '5': expanded = expanded + "and Sixty-Five";
    case '6': expanded = expanded + "and Sixty-Six";
    case '7': expanded = expanded + "and Sixty-Seven";
    case '8': expanded = expanded + "and Sixty-Eight";
    case '9': expanded = expanded + "and Sixty-Nine";
    case '7': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Seventy";
    case '1': expanded = expanded + "and Seventy-One";
    case '2': expanded = expanded + "and Seventy-Two";
    case '3': expanded = expanded + "and Seventy-Three";
    case '4': expanded = expanded + "and Seventy-Four";
    case '5': expanded = expanded + "and Seventy-Five";
    case '6': expanded = expanded + "and Seventy-Six";
    case '7': expanded = expanded + "and Seventy-Seven";
    case '8': expanded = expanded + "and Seventy-Eight";
    case '9': expanded = expanded + "and Seventy-Nine";
    case '8': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Eighty";
    case '1': expanded = expanded + "and Eighty-One";
    case '2': expanded = expanded + "and Eighty-Two";
    case '3': expanded = expanded + "and Eighty-Three";
    case '4': expanded = expanded + "and Eighty-Four";
    case '5': expanded = expanded + "and Eighty-Five";
    case '6': expanded = expanded + "and Eighty-Six";
    case '7': expanded = expanded + "and Eigthy-Seven";
    case '8': expanded = expanded + "and Eighty-Eight";
    case '9': expanded = expanded + "and Eighty-Nine";
    case '9': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Ninety";
    case '1': expanded = expanded + "and Ninety-One";
    case '2': expanded = expanded + "and Ninety-Two";
    case '3': expanded = expanded + "and Ninety-Three";
    case '4': expanded = expanded + "and Ninety-Four";
    case '5': expanded = expanded + "and Ninety-Five";
    case '6': expanded = expanded + "and Ninety-Six";
    case '7': expanded = expanded + "and Ninety-Seven";
    case '8': expanded = expanded + "and Ninety-Eight";
    case '9': expanded = expanded + "and Ninety-Nine";
    if(length == 1) {
    System.out.println("Length of 1 working....");
    switch(arr[1]) {
    case '0': {
    switch(arr[0]) {
    case '0': expanded = expanded + "";
    case '1': expanded = expanded + "and One";
    case '2': expanded = expanded + "and Two";
    case '3': expanded = expanded + "and Three";
    case '4': expanded = expanded + "and Four";
    case '5': expanded = expanded + "and Five";
    case '6': expanded = expanded + "and Six";
    case '7': expanded = expanded + "and Seven";
    case '8': expanded = expanded + "and Eight";
    case '9': expanded = expanded + "and Nine";
    case '1': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Ten";
    case '1': expanded = expanded + "and Eleven";
    case '2': expanded = expanded + "and Twelve";
    case '3': expanded = expanded + "and Thirteen";
    case '4': expanded = expanded + "and Fourteen";
    case '5': expanded = expanded + "and Fifteen";
    case '6': expanded = expanded + "and Sixteen";
    case '7': expanded = expanded + "and Seventeen";
    case '8': expanded = expanded + "and Eighteen";
    case '9': expanded = expanded + "and Nineteen";
    case '2': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Twenty";
    case '1': expanded = expanded + "and Twenty-One";
    case '2': expanded = expanded + "and Twenty-Two";
    case '3': expanded = expanded + "and Twenty-Three";
    case '4': expanded = expanded + "and Twenty-Four";
    case '5': expanded = expanded + "and Twenty-Five";
    case '6': expanded = expanded + "and Twenty-Six";
    case '7': expanded = expanded + "and Twenty-Seven";
    case '8': expanded = expanded + "and Twenty-Eight";
    case '9': expanded = expanded + "and Twenty-Nine";
    case'3': {
    switch(arr[0]) {
    case '0': expanded = expanded + "and Thirty";
    case '1': exp

    if(length == 3) {
    System.out.println("Length of 3, working...");
    //Assume we are starting at the one thousands
    //Since 0 is 1, we need to test for 3 for 1,000s not 4
    switch(arr[3]) {Arrays in Java start at index zero, so if the length of an array is 3, then the valid indices are 0,1 and 2.
    You also can make the whole thing much cleaner with using the way things are phrased in English - you say "one million, one hundred and fifty thousand, two hundred and seventy six pounds, thirty seven pence", so if you write a routine which converts an integer between 0 (inclusive) and 1000 (exclusive), and call that for the millions, thousands, units and cents in turn. You also might want to use localized strings in an array instead of coding everything as a sequence of switch statements.

  • Floating point precision of "Flatten to XML"

    It appears that the "Flatten to XML" function (LV 7.1.1) truncates floating point numbers to 5 decimal places.  This is a rather annoying limitation, since I'm trying to store a relative time in hours, accurate to the second (chosen by a previous coder that I have to be compatible with - otherwise I'd just use seconds).  Is there a workaround to this?  (other than multiplying by some power of 10 before flattening, and dividing after unflattening)
    Jaegen

    Hi Paul and Jaegen,
    I checked our databases and found entries of product suggestions and
    corrective action requests for the behavior of the limited precision
    when flattening to XML. I found an interesting reply from a LabVIEW
    developer on the request for further precision:
    The Flatten To XML primitive puposefully cuts off all numbers at 5
    digits after the decimal. There are 3 main reasons for this:
    Information regarding precision is not propagated on the wire.
    Therefore, there is no real way to know how many significant digits or
    even places past the decimal point is appropriate when data is
    flattened to XML.
    Bloat. If all floating point values printed all of the possible
    decimal digits all of the time, this would provide for some very large
    blocks of XML code.
    Given the arbitrarily complex nature of LabVIEW data, it is
    difficult to provide a method for specifying precision. For example, if
    a user has a cluster of clusters, each of which contain a single,
    double and extended representing various measurements of differing
    accuracy, how can one precision setting be applied to each of these
    values? The user would have to unbundle (and index if an array was
    involved), flatten, concatenate, and then the reverse on the unflatten
    side.
    I suggest that you go ahead and file a new product suggestion by using the "feedback" link on www.ni.com/contact.
    It would be best if you could give some detailed information on how you
    would like LabVIEW to handle different scenarios while getting around
    the above issues.
    Thanks for the feedback!
    - Philip Courtois, Thinkbot Solutions

  • Converting FLOAT to Date

    We have an application that stores dates as FLOATs in its Oracle tables. For example, since I'm writing this at 3:40 CDT on 05/25/2005, the FLOAT representation of this is 38497.6531944444. Via SQL, how can I convert this to a date that my eyeballs can understand? Thanks!

    Interestingly, though, when you copy and paste 38497.6531944444 into an Excel spreadsheet and change the cell format to Date, it returns the correct date of 05/25/2005, even though the Help section has this explanation with regard to how it converts the numbers to dates:
    "Microsoft Excel stores dates as sequential numbers which are called serial values. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900."
    That two-day difference between Excel and Oracle is curious. Perhaps because 1900 was not a Leap Year and MS considers 1 -- not zero -- as 01/01/1900? If so, if I hard-code 12/30/1899 into my report it'll be fine until 2100, which is not a Leap Year!

  • Convert float to Date

    We have swipe system , its transactions date are storing in float format. How to convert these float number to oracle dates.
    Below I have pasted the float numers, I am able to convert these float number using excel.
    Float Number
    =========
    40814.221528
    40814.221609
    40814.221505
    40814.223727
    After converting in excel
    ===============
    9/28/11 5:19 AM
    9/28/11 5:19 AM
    9/28/11 5:18 AM
    9/28/11 5:22 AM
    I will appreciate if some body can help

    Excel (and various other Microsoft products) store dates as a float value measured in "days since january first 1900". Your swipe system uses the same format to store dates.
    When you enter 40814.221528 in Excel and tell Excel to show the column as date, Excel is simply adding 40814.221528 days to january first 1900 and showing you the output of that calculation.
    In theory therefore we can in Oracle do the same calculation as Excel does by doing this:
    select DATE '1900-01-01' + 40814.221528 from dual;But like the previous answers show you, that gives a result that is two days "wrong".
    The reason for this is most likely two things:
    <li>Microsoft probably defines january first 1900 to be "day 1" and not "day 0".
    <li>Microsoft looks like they have an error in leap year calculation.
    Therefore we can simulate the Microsoft behaviour by offsetting by two days:
    select DATE '1900-01-01' - 2 + 40814.221528 from dual;Which is the same as doing this:
    select DATE '1899-12-30' + 40814.221528 from dual;Excel is doing the same thing - adding the float value to a fixed date ;-)

Maybe you are looking for

  • Material Status Report

    Hi Gurus, Is there any standard report for Material status. we are maintaining the status in OMS4. which we are using in Material Master like Blocked for procment/whse Blocked for task list/BOM These statuses for a particular material, i would like t

  • JFileChooser set focus to specific directory

    Is it possible to set the JFileChooser to grab focus on the previous selected directory in directory only mode from the textfield containing the selected file name? The behavior I am seeking is to show the chooser with a directory already selected an

  • Nothing stored in php error_log filename

    hi: i modified the php.ini file to define a file for logging errors. however, nothing is stored in it no matter what kind of php error i provoke. i checked with phpinfo() and the path is correct error_log /.../.../logs/php_error_log as the server is

  • When I saved an Illustrator CS6 file to EPS format, I got "could not complete the requested operation. unknown error."

    When I saved an Illustrator CS6 file to EPS format, I got "could not complete the requested operation. unknown error." Google it and find some temp fix. run the illustrator by using "Run as admin" mode and fix the problem, but when use run as, can't

  • After effect 7 pro crash after update osx to 10.4.7

    Topic After effect 7 pro crash after update osx to 10.4.7 Robinmaster - 03:53am Aug 2, 2006 Pacific Hi all write this messages bacouse i have a problem with start up of my AE 7 pro. AE7 pro crash when boot after initialization of GUI. try remove a op