How 2 extract 2 decimal places from a float variable

Hiya,
I have a float variable say x with a value 10.56879, how do i extract 56 without rounding it up. I want to store 56 in an integer variable after extracting it from float.
Cheers
Deepak

This works when f is positive,
float f = 10.56879f;
int i = Math.round((float)Math.floor(((f - (float)Math.floor(f))*100.0f)));
System.out.println(i);

Similar Messages

  • Removing Decimal Places from Graph labels

    One axis on my graph is showing decimal places despiting formatting the report field to show 0 places - the graph is reading decimal places directly from the database underneath the report .  Other than editing each axis label manual (or editing the original database field) does anyone know of another way I can elimate the decimal places from the graph?

    That solution only works for the x-axis but not the y-axis (or the other way round, depending on whether the chart is horizontal or vertical).
    The values of the y-Axis are formatted according to the default Number Formatting. If you can afford this, change the default number formatting to 0 decimal places.
    Another workaround would be to create a formula. Let's say amount was your database field. Then the formula would be
    ToText({AMOUNT},0)
    Put that in your chart instead of the original database field.
    Cheers,
    Florian

  • How to restrict the decimal place of a floating point number?

    Hi,
    Here is my code:
    public void TwoDecimal(double u){
         String w = Double.toString(u);
         int c = w.length();
         System.out.println(c);
         if (c <= 5)
            double a = Double.parseDouble(w);
            System.out.println(a);
         else
            System.out.println("Invalid input!");
      }I want to show a floating point number which has 2 digits and 2 decimal places, e.g. 45.82, 29.67. This number is input by user and passed as a parameter.
    For those case like the above sample floating point numbers, it can display the proper value of 'c'. e.g. 45.67 will display 5.
    However, when I passed 99999, it will show 7; 9999 will return 6, not 5.
    So, if the user does not input the '.', does it append 2 implicit chars to it? i.e. 99999.0 and 9999.0. So, that's why it returned 7 and 6 for the length of the string respectively.
    How can I fix it?
    and
    Does it has better algorithm?
    Pls advise.
    gogo

    When dealing with a known precision, in your case hundredths, it is often a good idea to use an integer type and add in the decimals on printing only. This is often the case in banking systems. Almost all of them use integer types, (read long) in pennies to store monitary values. Ever seen someone type in a value for a credit card machine? For something like $20 they press.. "2" "0" "0" "0" The machine knows the lowest denomonation in a cent, so it knows where to put the decimal place. I suggest you do something like this. It also helps to avoid base 2 round off errors.
    -Spinoza

  • @ Decimal Places in Packed Type Variable

    How to check if a packed type variable has decimal placed or not?

    Hi,
    Try to use the statement DESCRIBE. See the help to understand the usage. The syntax is:
    DESCRIBE FIELD <field> DECIMALS <dec>.
    This will show the number of decimals place.
    Then, you can use a condition to test.
    Regards
    RP

  • Changing of decimal places from 2 to 6 digits

    Hi,
    Currently, our PO price and GR/GI quantities are being limited to two (2) decimal places only. However, we want to maintain it into six (6) digits so that we can have a more accurate PO price and GR/GI quantities in our record.
    We tried to do this in Tcode OY04 but the system issued as the following warning messages:
    1. In a productive system, you must not delete the currencies in use or change the decimal places. This could make amounts in document already posted incorrect or invalid.
    2. In the R/3 System tables currency fields are stored as decimal figures with a variable number of decimal places. The decimal point is not stored in the field in the database. Instead, each currency field refers to a currency key field. In this transaction you assign the number of decimal places to this currency key uniquely.
    Can you please explain to me the warning messages further?
    Thank you.

    Hi Jack,
          Please never try to change the decimal places in PRD system, you will be in deep deep trouble.
    Let me give one example , If the current decimal is set to 2 digit and you are going to change it 3 digit, then  USD 100.00 will become  USD 10.000 for the already posted document.
    Please not that, the decimal places are not sotred in the database, when you run a tcode to see any posted data the system queries the currency table and see the value for the decimals, if it finds 3 in OY04, it simply places the decial point afer 3 digit from right, if the decimal is set to 4m it will simple place the decimal point after 4 digit from right.
    Hope this clears your doubt.
    Best Regards
    Hari K.

  • How extract a value from table?

    how extract a value only from table with labview 5.0?

    Hi T4l
    I modified you VI to extract a selected row from the table. This is quite simple by done by using the index array function. Hope this helps
    B Bakels
    Labview CLD , Engineer/Manager
    Promedes and DSM
    using LV 7.1, 8.0, 8.2, 8.5 and 2009 SP1
    http://www.promedes.nl
    Attachments:
    Untitled 2.vi ‏16 KB

  • Printing two decimal places from BigDecimal values

    I am using BigDecimal to represent money values. My output needs to line up so that (with a non-proportional font) the decimal point and the two decimal places are in the same columns for each line. But when the dollar value has zero cents, or has a number of cents that is divisible by ten, it drops the trailing zeroes, and drops the decimal point if the decimal places are both zeroes. For example, I want to see "25.00" instead of "25" and "25.50" instead of "25.5". It doesn't seem to make any difference if I set the scale to 2. (I have resorted to getting the toString() of the BigDecimal and hacking the string before I display it, but surely there must be an easier way?)
          BigDecimal aaa = new BigDecimal("25");
          BigDecimal bbb = new BigDecimal("25.0");
          BigDecimal ccc = new BigDecimal("25.00");
          BigDecimal ddd = new BigDecimal("25.5");
          BigDecimal eee = new BigDecimal("25.50");
          BigDecimal fff = new BigDecimal("25.75");
          aaa.setScale(2);
          bbb.setScale(2);
          ccc.setScale(2);
          ddd.setScale(2);
          eee.setScale(2);
          fff.setScale(2);
          System.out.println("SCALE SET TO 2: ");
          System.out.println("aaa = " + aaa);
          System.out.println("bbb = " + bbb);
          System.out.println("ccc = " + ccc);
          System.out.println("ddd = " + ddd);
          System.out.println("eee = " + eee);
          System.out.println("fff = " + fff);produces this output:
    SCALE SET TO 2:
    aaa = 25
    bbb = 25.0
    ccc = 25.00
    ddd = 25.5
    eee = 25.50
    fff = 25.75Thanks,
    Martin

    Thankyou Dr. Clap. This solved my problem - I added an LHS to the setScale statements:
          aaa = aaa.setScale(2);
          bbb = bbb.setScale(2);
          ccc = ccc.setScale(2);
          ddd = ddd.setScale(2);
          eee = eee.setScale(2);
          System.out.println("SCALE SET TO 2: ");
          System.out.println("aaa = " + aaa);
          System.out.println("bbb = " + bbb);
          System.out.println("ccc = " + ccc);
          System.out.println("ddd = " + ddd);
          System.out.println("eee = " + eee);produced:
    SCALE SET TO 2:
    aaa = 25.00
    bbb = 25.00
    ccc = 25.00
    ddd = 25.50
    eee = 25.50

  • How change decimal separator from . to ,

    Hi
    I need change the decimal separator from . to ,
    and apply ZZZ.ZZ9,99
    thanks

    There are a number of ways in which you can change these characters. They can be changed for all jobs by updating the jfmerge.ini, or for a single job by using command line options.
    You can update the jfmerge.ini either in an editor, or by using Central Control.
    In an editor you will update the entries for CurrencyComma (, by default) and CurrencyDot (. by default).
    In Central Control go to the 'Configuration' menu item, then select 'Configure Central and Agents', then select 'Print Agent' and Edit. Then select the 'Currency' button. You can now modify any of the currency options.
    On the command line you can enter -acucc=. for the thousand separator, and -acucd=, for the decimal separator.
    For more info on these options see the -acu Option Arguments in the Print Agent documentation.

  • Decimal places: Using Textsybols as variable

    Hi Freinds,
    is it possible to use variable as decimal indicator anf if yes please how.
    &symbol(E.2)& = two decimal
    my intension:
    &symbol(E.2)& = to replace 2 with variable e. g. &QAMV-STELLEN&
    Thanks,
    Blacky

    Hi ,
    Please create a subroutine pool to get the desired output. please see the documentation of text symbols below:
    Text Symbols
    All symbols that do not correspond to one of the three types of symbols described above are text symbols. You define the value of a text symbol yourself in the text module.
    There are two ways of doing this:
    In the text editor, choose Include ® Symbols ® Text.
    All the text symbols contained either in the current text or in a form assigned to the text are displayed. You can assign a value of up to 80 characters to a text symbol. Enter this value in the same form as it is to appear in the output.
    The effect of assigning a value is temporary, since the values assigned are not stored with the text but are lost as soon as you leave the editor. You use this kind of value assignment if you had a ready-made text containing symbols that you want to print with specific values in place of the symbols, and you want to do this only once without storing the u2018changedu2019 text.
    In the text, use the control command DEFINE.
    Since control commands are stored with the text module, any value you assign in this way is preserved when you save the text. You can change the value assigned to a symbol in the text at any time simply by issuing another DEFINE command.
    Remember always to use the ' (inverted comma) character to delimit a value. The maximal length for these values is also 80 characters.
    Regards,
    Chandra kavali

  • *SELECT: How to select value from cube into variable?

    Hi,
    I have an application that need lots of complex calculations.  Currently I am facing problem in retrieving a value from BPC application/database (BW cube) into a script logic local variable.  Let's say the application has  these  following dimensions
    1.  FYPD ( fiscal yr period. 200901, 200902 etc)
    2.  REGION ( A, B , C , D etc)
    3.  PRODUCT(Product ID)
    4.  VERSION ( ACTUAL, FORECAST etc)
    5.  AMOUNT (Sales Amount, signed data )
    Now I need to extract the sales amount into a local valriable where REGION = "A" and  PRODUCT = "SMK-1234" and FYPD = "200905"  and VERSION = "ACTUAL"
    What's should be the equivalent SELECT command? I tried but could not figure out. Any help?
    Regards
    DipM

    Hi DipM,
    There isn't really a concept of local variables for values in script logic. Instead, you'll want to use *WHEN, *LOOKUP, or MDX statements.
    For example, this will copy the value you mention into the PLAN version:
    *WHEN REGION
    *IS A
    *WHEN PRODUCT
    *IS SMK-1234
    *WHEN FYPD
    *IS 200905
    *WHEN VERSION
    *IS ACTUAL
    *REC(FACTOR=1,VERSION=PLAN)
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    See *WHEN ([link|http://help.sap.com/saphelp_bpc70sp02/helpdata/en/36/339907938943ad95d8e6ba37b0d3cd/frameset.htm]) and *REC ([link|http://help.sap.com/saphelp_bpc70sp02/helpdata/en/25/8d51050c43496887ddff88f13e5f1a/frameset.htm]) documentation for more.
    As mentioned, you can also use *LOOKUP or MDX statements to look up values and drive calculations in *REC(EXPRESSION=....) statements. This functionality is outlined in the SP02 documentation addendum ([link|http://service.sap.com/~form/sapnet?_SHORTKEY=00200797470000088146&_SCENARIO=01100035870000000202&]).
    In the MS Version of BPC, there is a concept of local MDX variables that work with the specialized *GO script logic statement. This statement is not available in the Netweaver version.
    Ethan

  • How extract the HTML from a mail

    Hi,
    How can I extract the HTML body of a Novell Groupwise mail item using the APIs. This HTML also need to have the embedded images, which can even be reffered from a local folder.
    A sample code in VB or a some references would help. Please advice.

    In 8.0, we expose the content-type and content-id
    of the attachments.
    The HTML message body attachments are grouped
    together as attachments. The text.htm attachment
    is first followed by any embedded graphics
    attachments. Each embedded graphic attachment
    will have an content-id value.
    The logic is to get the text.htm attachment and
    any following attachments that have a content-id
    until there is not an attachment or an attachment
    does not have an content-id.
    Preston
    >>> On Friday, February 12, 2010 at 8:06 AM,
    DamianPM<[email protected]> wrote:
    > Thanks.
    >
    > The embedded images in the HTML has the following within the img tag,
    > src="cid:[email protected]"
    >
    > The attachment collecection does not have a image004.jpg but has a
    > image.jpeg
    >
    > How can these images be linked or update the image tags so that it
    > picks the image from a local folder.
    >
    > The HTML preview of the email in NGW email application shows the
    > embedded images correctly.

  • How to bind data from script created variable to embed element of XML schema (xsd) in "Data View"

    Hi, i have got another problem with livecycle designer scripting.
    I have got script line which is defining of string variable:
    var aaa = "this is my string";
    and i have got embed XML schema like this (it`s only short part of whole file):
    ... xs:element name="bbb" type="xs:string"/ ...
    After saving data to XML i would like to get "this is my string" as a value of my "bbb" XML element.
    To save this data i`m using submit button which is connect with submit.php file on my server.
    How to connect script created variable and embed XML schema element which is present on my "Data View" tab.
    Please help me a bit becouse i don`t know even where to search answer of it...
    Of course i know possibilities to create fake unvisible text field object and bind it with 'bbb' and than put "this.rawValue = aaa" to connect those two variables but i think that is not a good idea to solve it in that way. It`s too primitive

    i solve it, i should write this:
    xfa.datasets.data.bbb.value = aaa;

  • To extract a day from a Date variable

    Hi
    I have a date variable and i want to get the day into a PL/SQL variable.Can you tell me how to do that .
    eg I have 12/30/2002 (MMDDYYY)
    and i want 30 in another variable ..
    Thanks in a advance

    SQL> declare
      2  ln number;
      3  begin
      4  ln := to_char(sysdate, 'DD');
      5  dbms_output.put_line(ln);
      6  end;
      7  /
    22
    PL/SQL procedure successfully completed.
    SQL>
    [pre]
    Piece of cake.  No, thanks, I've just had breakfast.
    APC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to pass value from templates to variables

    I have a part of my stylesheet(xslt)like the below example:
    <xsl:variable name="amount">
    <xsl:call-template name="amountaggregate">
    <xsl:with-param name="sum">
    <xsl:value-of select="number(0)"/>
    <xsl:with-param>
    <xsl:with-param name="cucount">
    <xsl:value-of select="number(1)"/>
    </xsl:with-param>
    </xs:call-template>
    </xsl:variable>
    in my template "amountaggregate" i will be setting a maximum count and will be incrementing the cucount by 1 each till cucount=maxcount. For each increment i will be adding some values to the parameter sum. i need to assign the final value of sum to the variable amount so that i can access it by "$amount"
    Can anyone help me?

    Hi,
    Some of the tutorials for the ABAP WebDynPro
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/02e1fa45-0801-0010-10a0-f1cf47e8c943
    for your question ,
    1. you should have two views and a Node in the Component controller
    2. In the first view you should bind the Component controller node attribute Employee ID.
    3. In the second view also u should bind the Employee id attribute and get the value from that and process the employee id.
    4. Display the employee Details in the Second view.
    all the business Logic please write in the component conntroller.
    the Data will pass like this
    FirstView Context --> Component controller Context --> Second view Context.
    here Component controller context is Global and can be visible to both the views.
    Reward if usefull.
    Regards,
    Ravi.

  • How to get data from rich:dataGrid variable to backing bean

    Hi,
    I have a problem in the following code. I have a dataGrid and I display data in the data grid by calling an array (bean.list). The array is displayed as pictures in JSF and the user clicks on one of those images. (more like a shopping card)
    My question is once the user selects a picture, I want to get some details (e.g.price) and store it back in my bean class for later use.
    Please tell me how I store the data back to the bean class.
    <rich:dataGrid border="0" value="#{bean.list}" var="item"  columns ="2" >
           <h:panelGrid border="0" columns="2">
    <a4j:commandLink onclick="#{rich:component('modalPanel')}.show()"><h:graphicImage value="/images/#{item.imageName}"  /> </a4j:commandLink>
    <h:outputText value=" #{item.price}" /> bean.list is stored in the DB and once I display all the product images in JSF, the user clicks on any picture.
    I want to get some information (item.price) from that item and store it back in the bean class. And probably some other information (e.g.item.date) from the item.
    Thanks for your help
    Edited by: shana10 on Nov 18, 2009 10:45 PM

    private function onItemClick( e:ListEvent ):void
         alert=Alert.show(experimentdetails.getItemAt(e.rowIndex).experimentName.toString());
    The ListEvent has a rowIndex and a columnIndex property that you can use to find out the record/attribute that was clicked.
    Does this solve your query ?
    Balakrishnan V

Maybe you are looking for