Convert string '1.245.201' to decimal number ?

Hi all,
i've a variable like this :
DATA g_base TYPE HRPAD_CHAR11 .
if g_base equal '100' following instruction work fine :
if g_base = 0.
endif.
Now, if g_base equal '1.434.236', program dump.
How can i do to resolve this ?
note : it's a standard SAP program, and there are not SAP Note for resolve.

hi tafkap,
1. IF_CA_MAKE_STRING_NUMERICAL
   Use the above FM to test
   whether the field is numeric or not.
( use this FM Before any comparison,
  ie.
  Before
if g_base = 0.
endif.
2. HRPAD_CHAR11 is CHAR(11).
3. If u want to compare / convert
    to numeric,
  u can check FIRST,
  and then assign it to numeric variable.
regards,
amit m.
Message was edited by: Amit Mittal

Similar Messages

  • 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

  • How can I extract high and low parts of a string that represents a 64bits decimal number?

    I want to extract the high and low parts to interpret it and convert to binary code, but such a hugh number (represented by a string) isn't easy to extract from the string directly its high and low parts.

    LabVIEW can't handle a 64-bit integer. You will have to store it as two 32-bit integers. If you need exact math on those 64-bit intergers you will have to make up your own routines to handle the carries and what not. If you just need pretty good accuracy, covert both 32-bit integers to double, multiply the upper 32-bit number by 2*32 (also a double) and then add the lower 32-bit number to it.
    Good luck.

  • Program to convert binary to decimal number?

    I only know how to do a program that converts only 4 numbers, but it to convert any amount of digits the number enters, I think you need to use a loop or something, but I'm not sure how. Could someone please help me? This is my code so far:
    import javax.swing.JOptionPane;
    public class bintodec {
         public static void main (String[] args) {
              String input;
              int number,digit1,digit2,digit3,digit4,result;
              input = JOptionPane.showInputDialog ("Enter a binary number.");
              number = Integer.parseInt(input);
              digit1 = ((number % 10000) - (number % 10000 % 1000)) / 1000;
              digit2 = ((number % 1000) - (number % 1000 % 100)) / 100;
              digit3 = ((number % 100) - (number % 100 % 10)) / 10;
              digit4 = (number % 10);
              result = (digit1 * 8) + (digit2 * 4) + (digit3 * 2) + (digit4 * 1);
              System.out.println ( "Binary number: " + input + "\nConverted Decimal Number: " + result);
              System.exit( 0 );
         } // main
    } // bintodecany help is super-appreciated.

    I am not sure if this will help you. Check it out, run it and let me know if it helped.
    import java.util.*;
       public class BitwiseTest1 {
           public static void main(String[] args){
            System.out.println("Enter a integer number:");
            Scanner keyboard = new Scanner(System.in);
            int n1 = keyboard.nextInt();
            System.out.println( "n1 as binary " +
                   Integer.toBinaryString( n1 ));
            System.out.println( "NOT n1 =     " +
                   Integer.toBinaryString( ~n1 ));
            System.out.println("Enter another integer number:");
            int n2 = keyboard.nextInt();
            System.out.println( "n2 as binary " +
                   Integer.toBinaryString( n2 ));
             System.out.println( "NOT n2 =     " +
                   Integer.toBinaryString( ~n2 ));
    }

  • Converting to decimal number

    Hi to all,
    I am diplaying data from the DataControl on a page, these data is numbers and are shown as:
    number1: 12.154
    number2: 125.25
    number3: 1.254
    as seen with a decimal point, are not aligned and with more than two decimal numbers.
    How can I make show like this?
    number1: 12,15
    number2: 125,25
    number3: 1,25
    numbers with decimal comma, aligned and only two decimal numbers. I saw that this is possible using UI Hints,but I can not get it, someone can help me?

    krd12 wrote:
    I am trying to convert a string with a lot of digits (ex 324.41897635) into a number and want to get back the same precision in the number as in the string. I tried the "Decimal String to Number" (get back no digits after decimal point ex 324) and "Frac/Exp String to Number" (get back three decimal places rounded ex 324.419) 
    Not a trivial exercise!
    Here is 1 possible solution I've limited it to non-trivial digits (ext floats are only 15 digits precise on some OS's.)  But you can see the steps necessary.  I assume the radix symbol is "." but the vi could be modified to use"System Decimal Seperator"
    Jeff
    Attachments:
    Max Str-Ext.vi ‏11 KB

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • 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 .

  • Essbase 9.3 Calc scripts. Pb with dates. How to convert (string = number) ?

    Hello,
    I've a problem with Essbase(Planning?) Scripts on version 9.3. It looks simple but I do not find any (clean) solution :
    On my Essbase database, I have a member called "Reference_Date" on my axis Indicators. It is a date data type, that is to say, it displays a number corresponding to a YYYYMMDD format. For example : 20091029 for October 29th 2009.
    In calc scripts I often need to compare the month included in that "Reference_Date" with the current Member of my Time Axis (I have 12 Months members based on the format M02 for February for example). The final aim is to calculate a number of complete years since that "Reference_Date".
    But theses two elements are not of the same "type" (one is a number value and the other is a "member" in Time Axis). So I'm forced to convert one of this two elements in order to compare it.
    For example I can extract the month value of the "Reference_Date"' and put an "M" before it to have a Time member equivalent or I can convert the member Name M10 to a number (10))
    in both cases I have the same type problem : I don't know how to convert a string into a number nor how to convert a number into a string.
    (For example @CONCATENATE doesn't work with numbers). and that my only remaining problem.
    I didn't find any Essbase Function which do this (conversion number <=>string).
    Is anyone have an Idea ?
    Thanks for your help
    Best regards

    I don't know any way for you to compare your data against your metadata. Not directly. To me it makes little enough sense to try that I'm not surprised the developers didn't provide for it.
    I've converted member names to strings, manipulated the strings (calc script functions are not good at this), and turned them back into member names, but that's really the only use I've had for string manipulation. I don't think an equivalency operator even exists for string data. And I see no way to begin thinking of a member name, once converted to a string, as a number.
    It makes even less sense to me to try thinking of a data value as a string. Even text values in Sys 11 are stored as numbers. Not encoded characters, but just a number to look up somewhere.
    I think you can do what you want though, with something like this...
    IF (@ISMBR("FY08"))
    vYr = 2008;
    ELSEIF (@ISMBR("FY09"))
    vYr = 2009;
    ENDIF;
    IF (@ISMBR("M01"))
    vMth = 1;
    ELSEIF (@ISMBR("M02"))
    vMth = = 2;
    ENDIF;
    "Years_Since_Reference" = ((vYr * 100) + Mth) - ("Reference_Date" / 12);
    Obviously, the math will need some work, coz that doesn't actually work, but the logic above essentially turns your metadata into numbers, which is what you are after.
    Good luck,
    -- Joe

  • Converting strings to the floating number and plotting

    Hello,
    I have a question regardting converting string of numbers to the floating bumbers and plot for voltage vs. weight.
    The load cell for the ADC resolution is 16 bits, and the voltage will be in between +-5 volts.
    The problem, I have the most is converting the string of numbers to the floating numbers, in my case is the weight.
    Attachments:
    tunnelv1.vi ‏139 KB

    When you say "string of numbers" do you mean an array? What is the specific issue you are having? You seem to have orange wires running all over the place. Give a small example demonstrating the problem.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • 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 *

  • Round decimal number to two places

    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.
    -tried using math.round but it only rounds to nearest integer
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to double
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?
    any advice is appreciated:)

    coynerm wrote:
    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.Agree.
    -tried using math.round but it only rounds to nearest integerI advise against rounding in most newbie situations. Usually it's the display of the variable you want to change.
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to doubleOf course cast won't allow you to convert back. If you wanted to do that you'd use Double.parseDouble(stringVar); But we don't know why you are doing all this converting in the first place.
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?Advice: Forgetting all this fooha with rounding, what in essence are you trying to achieve? Why all of this number manipulation in the first place? It will affect what should be the best answer.

  • Logic of converting strings to integer

    Hi all,
    I know that , I can convert a string into a number using API , Ineger.parseInt() . But i want to know the reall algoritham behind that
    .Can anybody explane that ?
    Basically I am interested in
      String s = "123";
      int i = Integer.parseInt(s);
      But i want to know what is the logic running behind this ?. Can anybody please help me. ...?
    Thanks in advance....

    The decompiled version parseInt() from Integer class
         * Parses the string argument as a signed decimal integer. The
         * characters in the string must all be decimal digits, except that
         * the first character may be an ASCII minus sign <code>'-'</code>
         * (<code>'&#92;u002D'</code>) to indicate a negative value. The resulting
         * integer value is returned, exactly as if the argument and the radix
         * 10 were given as arguments to the
         * {@link #parseInt(java.lang.String, int)} method.
         * @param s        a <code>String</code> containing the <code>int</code>
         *             representation to be parsed
         * @return     the integer value represented by the argument in decimal.
         * @exception  NumberFormatException  if the string does not contain a
         *               parsable integer.
        public static int parseInt(String s) throws NumberFormatException {
         return parseInt(s,10);
         * Parses the string argument as a signed integer in the radix
         * specified by the second argument. The characters in the string
         * must all be digits of the specified radix (as determined by
         * whether {@link java.lang.Character#digit(char, int)} returns a
         * nonnegative value), except that the first character may be an
         * ASCII minus sign <code>'-'</code> (<code>'&#92;u002D'</code>) to
         * indicate a negative value. The resulting integer value is returned.
         * <p>
         * An exception of type <code>NumberFormatException</code> is
         * thrown if any of the following situations occurs:
         * <ul>
         * <li>The first argument is <code>null</code> or is a string of
         * length zero.
         * <li>The radix is either smaller than
         * {@link java.lang.Character#MIN_RADIX} or
         * larger than {@link java.lang.Character#MAX_RADIX}.
         * <li>Any character of the string is not a digit of the specified
         * radix, except that the first character may be a minus sign
         * <code>'-'</code> (<code>'&#92;u002D'</code>) provided that the
         * string is longer than length 1.
         * <li>The value represented by the string is not a value of type
         * <code>int</code>.
         * </ul><p>
         * Examples:
         * <blockquote><pre>
         * parseInt("0", 10) returns 0
         * parseInt("473", 10) returns 473
         * parseInt("-0", 10) returns 0
         * parseInt("-FF", 16) returns -255
         * parseInt("1100110", 2) returns 102
         * parseInt("2147483647", 10) returns 2147483647
         * parseInt("-2147483648", 10) returns -2147483648
         * parseInt("2147483648", 10) throws a NumberFormatException
         * parseInt("99", 8) throws a NumberFormatException
         * parseInt("Kona", 10) throws a NumberFormatException
         * parseInt("Kona", 27) returns 411787
         * </pre></blockquote>
         * @param      s   the <code>String</code> containing the integer
         *                representation to be parsed
         * @param      radix   the radix to be used while parsing <code>s</code>.
         * @return     the integer represented by the string argument in the
         *             specified radix.
         * @exception  NumberFormatException if the <code>String</code>
         *              does not contain a parsable <code>int</code>.
        public static int parseInt(String s, int radix)
              throws NumberFormatException
            if (s == null) {
                throw new NumberFormatException("null");
         if (radix < Character.MIN_RADIX) {
             throw new NumberFormatException("radix " + radix +
                                 " less than Character.MIN_RADIX");
         if (radix > Character.MAX_RADIX) {
             throw new NumberFormatException("radix " + radix +
                                 " greater than Character.MAX_RADIX");
         int result = 0;
         boolean negative = false;
         int i = 0, max = s.length();
         int limit;
         int multmin;
         int digit;
         if (max > 0) {
             if (s.charAt(0) == '-') {
              negative = true;
              limit = Integer.MIN_VALUE;
              i++;
             } else {
              limit = -Integer.MAX_VALUE;
             multmin = limit / radix;
             if (i < max) {
              digit = Character.digit(s.charAt(i++),radix);
              if (digit < 0) {
                  throw NumberFormatException.forInputString(s);
              } else {
                  result = -digit;
             while (i < max) {
              // Accumulating negatively avoids surprises near MAX_VALUE
              digit = Character.digit(s.charAt(i++),radix);
              if (digit < 0) {
                  throw NumberFormatException.forInputString(s);
              if (result < multmin) {
                  throw NumberFormatException.forInputString(s);
              result *= radix;
              if (result < limit + digit) {
                  throw NumberFormatException.forInputString(s);
              result -= digit;
         } else {
             throw NumberFormatException.forInputString(s);
         if (negative) {
             if (i > 1) {
              return result;
             } else {     /* Only got "-" */
              throw NumberFormatException.forInputString(s);
         } else {
             return -result;
        }

  • About binary number and decimal number?

    how to use a class to convert a decimal number from a binary number?Thank you

    You've already asked the same kind of thing before (http://forum.java.sun.com/thread.jsp?forum=31&thread=325249), and fsato4 answered. Here is the same thing, but decimal to binary.
    public class ToBinary {
         public static void main(String[] args) {
              int n = 12; 
              System.out.println(Integer.toString(n)); 
              System.out.println(Integer.toBinaryString(n));

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • 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

Maybe you are looking for