Comma or point in decimal number

Hi,
I wonder how to handle decimal number input from jsp page with comma or point. Is there a way to take care of this automatic so a comma get parsed to a point or vice versa.
Thanks in advance.

I don't know if it will be a comma or a dot that is inputed. My keyboard uses a comma on the numeric pad but if i change it to a US keyboard it will use dot instead so I can't tell what a user will input. And if I understand everything when java calculates a double it has to be with a dot, or am I completly wrong.
So with this in mind i decided to replace all dots with a comma and then parse it to a double with NumberFormat and do my calculation and then format it with NumberFormat again. This works fine and gives me a nice output if no one tries to input more than one point or comma.
I can't think of another way to do it so if this is completly wrong so please point me in the right direction.

Similar Messages

  • Why does TestStand use both comma and period for decimal point separation?

    TestStand stores our test data to a SQL server using SQL Server Stored Proc, but for some reason a comma is used for separation (double values) for "PROP_NUMERICLIMIT.HighLimit" and "PROP_NUMERICLIMIT.LowLimt", but not for "PROP_RESULT.Data" (or any other numeric value field). Why is that? I haven't been able to figure out if it is a bug or if I have missed some step in the configuration.

    I ran across this in the TestStand Help. You might want to try the change in the ODBC Administrator.
    When you use the MySQL ODBC driver and the operating computer specifies a comma character as the decimal symbol character, the ODBC driver might return an error because the ODBC driver internally converts a floating-point value to a string value. The computer locale causes MySQL to interpret the comma decimal symbol character in the SQL syntax as a multi-value list character separator. Configure the MySQL data source in the ODBC Administrator and enable the Don't Use Set Locale option in the Miscellaneous Options section to resolve this error.

  • Decimal points appearing for number in flat file upload

    Hello
    I am trying to upload a .csv file to a datasource. It is a number but when I see it in preview I am getting a decimal number with 3 points.
    Can you tell me what I am doing wrong?
    Thank you
    Ravi

    Hello Durgesh
    Thank you for the reply.
    I am new to BI. I am just trying to upload a flatfile to Datasouce.
    I have created InfoObject with NUMC 4. The thing I am not able to get is, when we are uploading a file from source system to datasouce, I am at an understanding that there is no link between the field type we are using for the infoObject and the .csv file data in the data source. Please correct me if I am wrong.
    So even before creating the transformation, by just loading and looking at the preview of data in datasouce itself, I am seeing decimals for number. I even tried to make the data file in notepad and save as .csv inorder to avoid any cimplications with excel.
    Please advice.
    Thanks
    Ravi

  • Problem with comma and point

    Hello,
    I have a problem with comma and point in a double-digit.
    I use a english driver for HM8142. When I get the values then I only get
    int-digits. How can I change "Use comma as separator" . I tried to change
    the option in LabVIEW.
    I changed it, then I got the window. "To change, restart the programm". I
    have done this. But when I have a look at the option, it is not changed.
    What can I do?
    I am not the admin on the computer.
    Martin

    Hi Martin,
    you do not have to change any system settings neither in LabVIEW nor in your windows.
    All instrument drivers should use a point as decimal separator. You can overwrite the decimal point handling in the string functions "Scan from string" and "Format into string".
    Make a right click on the function and use "Edit Scan String". In the dialog open the ring under "Selected operation", the last entry allows you to set the character for the decimal separator. This separator will be used for all the following floating point numbers.
    From your name and problem I think you are located in central europe. I do not have a german version of LV so I cannot tell you how the elements are named in german.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • I can't use a decimal number in a update routine

    Hi,
    I want to use a decimal number in a udate routine (in a updating rule). I've a code similar to this:
    IF COMM_STRUCTURE-/BIC/ZSATIAUX1 LT 1,5.
      RESULT = 'GOOD'.
    And when I save the routine I get the following error:
    E:Comma without preceding colon (after IF ?).
    The COMM_STRUCTURE-/BIC/ZSATIAUX1 field is numeric field with three decimal positions.
    Can anybody tell me why I can't use decimals in my routine?
    Thanks in advance.
    Regards.

    Hi,
    Try following code:
    Data: Val type COMM_STRUCTURE-/BIC/ZSATIAUX1 .
    val = 1.5.
    IF COMM_STRUCTURE-/BIC/ZSATIAUX1 LT val.
    RESULT = 'GOOD'.
    endif.
    Regards,
    Geetanjali

  • How to convert fractional decimal number to hex number?

    Hi,
    Can any one help me to convert the fractional decimal number to its equivalent hex number and vice versa ?
    if u have any code please share.
    thanks
    neethu

    neethukk wrote:
    Can any one help me to convert the fractional decimal number to its equivalent hex number and vice versa ?
    if u have any code please share.
    This question is not clear at all.
    "Fractional decimal" is not a data type, but a way of formatting in readable form using numeric characters and a decimal separator.
    Same to "hex number", but only for integers.
    What do you mean by "convert"? Do you want to keep the value the same or retain the bit pattern of the numeric data type?
    Hexadecimal is for integers. Are you talking about fixed point?
    We clearly need significantly more information. What are the input and output data types? What are you actually trying to do?
    Do you have an example input and corresponding output?
    LabVIEW Champion . Do more with less code and in less time .

  • How to convert data read in byte to decimal number?

    The following are a source code to read from a serial port, but i can't convert the data that i read to decimal number and write it on a text file.....can anyone kindly show me how to solve it? thanks
    import javax.comm.*;
    import java.io.*;
    import java.util.*;
    public class Read implements Runnable, SerialPortEventListener {
         // Attributes for Serial Communication
         static Enumeration portList;
         static CommPortIdentifier portId;
         SerialPort serialPort;
         static OutputStream outputStream;
         InputStream inputStream;
         Thread readThread;
         public static void main(String s[])
         portList=CommPortIdentifier.getPortIdentifiers();
         while(portList.hasMoreElements())
              portId=(CommPortIdentifier)portList.nextElement();
              if(portId.getPortType()==CommPortIdentifier.PORT_SERIAL)
                   if(portId.getName().equals("COM1"))
                        System.out.println( portId.getName());
                        Read ss=new Read();
              }     // end of while
    }          // end of main
    public Read()     {
    try{
              serialPort=(SerialPort)portId.open("Read", 2000);
    catch(PortInUseException e)     {}
         try{
              inputStream=serialPort.getInputStream();
              System.out.println(inputStream);
    catch(IOException e)     {}
         try{
              serialPort.addEventListener(this);
    catch(Exception e)     {}
              serialPort.notifyOnDataAvailable(true);
         try{
              serialPort.setSerialPortParams(9600,
              SerialPort.DATABITS_8,
              SerialPort.STOPBITS_1,
              SerialPort.PARITY_NONE);
              }catch(UnsupportedCommOperationException e)     {}
              readThread=new Thread(this);
              readThread.start();
         }//end of constructor
         public void run()
              try     {
                   Thread.sleep(200);
              }catch(InterruptedException e)     {}
         public void serialEvent(SerialPortEvent event)
              switch(event.getEventType())
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                   break;
                   case SerialPortEvent.DATA_AVAILABLE:
                   byte[]readBuffer=new byte[8];
                   try{
                        while(inputStream.available()>0)
                             int numBytes=inputStream.read(readBuffer);
                             //System.out.println("hello");
                        System.out.print(new String(readBuffer));
                        }catch(IOException e)     {}
                   break;
                   }     // end of switch
                   try     {
                        inputStream.close();
                        }catch(Exception e5)     {}
         }          // end of serialEvent

    Is it a float or a double?
    For a float, the decimal should be 4 bytes (small numbers like 1.1 start with the byte 0x40). Convert these 4 bytes to an int, using byte-shifting would probably be easiest.
    int value = ((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);//b# are bytesNow to convert it to a float, use
    Float.intBitsToFloat(value);Now if you want double percision, You will have 8 bytes instead of 4, and need to be converted to a long instead of an int through byte-shifting. Then use Double.longBitsToDouble(long bits) to get the double

  • Decimal Number Validation.

    Hi All,
    I'm working on Interface currently where I need to load data from flat file to db. I use the sql loader to load the data, but before I saved the data I need to validate certain fields. How i can validate do decimal number validation. For an example, 1.11 is valid and 1.111 is invalid (2 decimal level). When i do the validation i need to check the field so it contains 2 decimal points only. If i contains 3 decimal point the data is invalid. Appreciate if anyone can help me with this. Thanks alot.

    1. Will you want to load only valid data ??
    2. Fail the load if one such invalid data found?
    you need to use WHEN clause functionality in the sql loader - foe examples pls visit -
    http://psoug.org/reference/sqlloader.html
    WHEN clause shud look something like following -
    WHEN LENGTH(substr(:columnname,INSTR(:columnname,1,'.')+1,LENGTH(:columnname))) <=2Using above will load only records having one or two digits after the dot [upto 2 decimal]
    Assumption - Column name what ever you are choosing shud have only one decimal [one dot]in its designated start and end places.
    Hope this helps..
    [Untested]
    Edited by: Sri on Mar 22, 2011 8:34 PM
    Typo fixed.. :)
    Edited by: Sri on Mar 22, 2011 8:36 PM

  • How to read number of digits in a given decimal number by using abap

    Hi ,
    How can we read the number of digits present in a decimal number , just before decimal.
    For example: I have this number - 200.00
    Now I want to read how many digits are present in this number before decimal ( . ) point. so in this case the number of digits are 3( 200). Similarly if we have a number 15.00, in this case number of digits is 2 ( 15 ) before decimal point.
    How can i acheive this by using abap.
    Regards
    PG

    Hi
    There are differenent logics available.The previous reply was really good. get another way also.
    Data: v_dec type p decimals 3,
             v_temp   type char20,
              v1 type char10,
              v2  type  char10,
               v_len type i.
    v_temp   = v_dec.
    split  v_dec at  '.'  into v1 v2 .
    condense v1  no-gaps.
    len = strlen( v1 ).
    Regards,
    Chellamma Chandrasekar.

  • Regarding Converting the Decimal number into rounded value...

    Hi,
       i have a decimal number as "   58240990.00 " , i wanted this to rounded value .
      for example I am expecting to see 58241 for the above number.
      shell we can do in any way.. if so please let me knw fast.. it is urgent..
      thanks in advance.
    thanks,
    Suresh..

    Dear Suresh,
    Go through the following code chunk:
    DATA : p TYPE p DECIMALS 2 VALUE '2.49'.
    DATA i TYPE i.
    i = CEIL( p ).
    WRITE : i.
    Regards,
    Abir
    Don't forget to award Points *

  • Rounding off 2 decimal number

    Hi,
    How can i round up float number to two decimal number.
    For example
    Number is 45.987654532 then It should be rounded up to 45.98
    Number is 45.987654546 then It should be rounded up to 45.99Appriciated sample souuce (If any)
    Tanks in advance

    You could have a look at String's format() method. The format strings are
    described in detail here:
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.htmlpublic class Round {
        public static void main(String[] args) {
            double number = 45.987654546;
            String roundStr = String.format("%.2f", number);
                // Rounded is 45.99
            System.out.println("Rounded is " + roundStr);
                // The same thing
            System.out.printf("Rounded is %.2f%n",  number);
    }Note: these methods generate rounded Strings from floating
    point numbers. Also, they round to a string representing the "nearest"
    number - your first example is a little hard to understand in this regard.

  • How to convet a decimal number of in to base 64.

    Hi friends,
    my requirement is how to convet a decimal number of in to base 64.
    ex:decimal number could be any type 1,1.2,-1,-1.2 etc
    i found an API Base64.java but iam not able to use .
    Please Help me out.

    try this
    Typecast your array of integers to Byte[] and use method byteArrayToBase64() as:
    String encodeArray = Base64.byteArrayToBase64( new byte[]{ 3, 34, 116, 9 } );Also, browse the below link for more details
    http://kickjava.com/src/java/util/prefs/Base64.java.htm
    Message was edited by:
    Mayank_03

  • Interchange between Comma and point in J2I6

    Hi Friends,
    I am facing a problem in print of excise register (T code J2I6 ). In print preview of both RG23A part II and RG23C part II registers, there is interchange between comma and points i.e for amount fifteen thousand 15.000,00 is displaying instead of 15,000.00.
    I have checked the user setting and default format is correct. it is X 1,234,567.89.
    Please tell how can i make it correct.
    Thanks,
    Prasant

    hi
    check the form used and check the program routine used and if required correct it.

  • Removing leading spaces in a decimal number

    I have a decimal number field of length 28 with 9 spaces.I have to print it right justified and remove the leading spaces.I appreciate if anyone can let me the statement for this

    Hi,
      Try this..
    DATA: V_P TYPE P DECIMALS 2.
    V_P = '112.00'.
    WRITE: / V_P.
    DATA: STR TYPE STRING.
    STR = V_P.
    SHIFT STR LEFT DELETING LEADING SPACE.
    WRITE: / STR.
    Thanks,
    Naren

  • Add a date to decimal number

    hello
    pls tell me how to add a date to decimal number as
    4 years and 3 months for example ?
    EX.
    ===
    1/1/2001
    +
    4 years and 3 months
    Regards,
    Abdetu...

    If you want a specific result, then post your desired result...we don't know your desired format mask.
    In case it's yyyymmdd:
    SQL> select to_date('1/1/2001', 'dd/mm/yyyy') dt
      2  ,      add_months(to_date('1/1/2001', 'dd/mm/yyyy'), 51) dt2
      3  ,      to_number(to_char(add_months(to_date('1/1/2001', 'dd/mm/yyyy'), 51), 'yyyymmdd')) num
      4  from   dual;
    DT                  DT2                        NUM
    01-01-2001 00:00:00 01-04-2005 00:00:00   20050401
    1 row selected.

Maybe you are looking for