About NumberFormat question

import java.util.*;
import java.text.*;
public class TestPrintf{
public static void main(String[] args) {
String[] num = {
"123.3105",
"123.3115",
"123.3125",
"123.3135",
"123.3145",
"123.3155",
"123.3165",
"123.3175",
"123.3185",
"123.3195"
NumberFormat nf;
nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits (nf.getMinimumIntegerDigits());
nf.setMinimumFractionDigits (3);
nf.setMaximumFractionDigits (3);
nf.setGroupingUsed (false);
for(int i=0;i<num.length;i++){
System.out.println(num[i] +" ,NumberFormat "+nf.format (Double.valueOf(num).doubleValue()));
out is:
123.3105 ,NumberFormat 123.310
123.3115 ,NumberFormat 123.312
123.3125 ,NumberFormat 123.312
123.3135 ,NumberFormat 123.314
123.3145 ,NumberFormat 123.314
123.3155 ,NumberFormat 123.316
123.3165 ,NumberFormat 123.316
123.3175 ,NumberFormat 123.318
123.3185 ,NumberFormat 123.318
123.3195 ,NumberFormat 123.320
I want to know, when last number is "5", number before "5" is "0" "2" "4" "6" "8",why "5" will be cut ,and "1" "3" "5" "7" "9" will add 1
how to rewrite this java code, and make result as
123.3105 ,NumberFormat 123.310
123.3115 ,NumberFormat 123.312
123.3125 ,NumberFormat 123.313
123.3135 ,NumberFormat 123.314
123.3145 ,NumberFormat 123.315
123.3155 ,NumberFormat 123.316
123.3165 ,NumberFormat 123.317
123.3175 ,NumberFormat 123.318
123.3185 ,NumberFormat 123.319
123.3195 ,NumberFormat 123.320
thanks!
[email protected]

import java.util.*;
import java.text.*;
public class TestPrintf {
    public static void main(String[] args) {
        String[] num = {
            "123.3105",
            "123.3115",
            "123.3125",
            "123.3135",
            "123.3145",
            "123.3155",
            "123.3165",
            "123.3175",
            "123.3185",
            "123.3195"
        NumberFormat nf;
        nf = NumberFormat.getInstance();
        nf.setMinimumIntegerDigits (nf.getMinimumIntegerDigits());
        nf.setMinimumFractionDigits (3);
        nf.setMaximumFractionDigits (3);
        nf.setGroupingUsed (false);
        for(int i=0;i<num.length;i++) {
            System.out.println(num[ i ] +" ,NumberFormat "+nf.format (Double.valueOf(num[ i ]).doubleValue() + 0.0001));
}This prints:
123.3105 ,NumberFormat 123,311
123.3115 ,NumberFormat 123,312
123.3125 ,NumberFormat 123,313
123.3135 ,NumberFormat 123,314
123.3145 ,NumberFormat 123,315
123.3155 ,NumberFormat 123,316
123.3165 ,NumberFormat 123,317
123.3175 ,NumberFormat 123,318
123.3185 ,NumberFormat 123,319
123.3195 ,NumberFormat 123,320
I guess that is what you meant (note: first number prints 123,311 instead of 123,310).
Jesper

Similar Messages

  • HT5312 Hey I forgot about the questions and answers, and when the balance of $ 15 and I want to buy software from iTunes for regrettably I could not and I were sent to you many not thrown a response, or retrieve answers frankly tired or help me and send E

    hey i forgot about the question and answers and when the balance of 15d and i want to buy software form i tunse for regettably i could

    The page that you posted from has instructions for how to reset them i.e. if you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then steps 1 to 5 half-way down that page should give you a reset link.
    If you don't have a rescue email address (you won't be able to add one until you can answer your questions) then you will need to contact iTunes Support / Apple in your country to get the questions reset (these are user-to-user forums).
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 page that you posted from to add a rescue email address for potential future use

  • HT5624 Sir, I have my id and pass but I can't change or edit my secret question and answer B'coz when I creat my id I didn't entered 2nd mail option that's why I forget my info about secret question . Naw I want to reset my secret question and answer,plz

    Sir, I have my id and pass but I can't change or edit my secret question and answer B'coz when I creat my id I didn't entered 2nd mail option that's why I forget my info about secret question . Naw I want to reset my secret question and answer,plz help me out

    You need to contact Apple to fix this. Pick your country here:
    http://support.apple.com/kb/HT5699?viewlocale=en_US

  • TS3297 When I try to buy a song from iTunes it says something about security questions and when I type them in it says they are not valid and won't let me download the music?!

    iTunes Store is not letting me purchase any songs. When I download them it says something about security questions and when I type them in it says they are incorrect when they are! Hiw can I download song?

    Click here and search the article for '2 out of 3' without the quotes; in the case of forgotten answers, this generally involves either a message being sent to your rescue email address or contacting the iTunes Store staff directly.
    (74834)

  • Simple question about NumberFormat [really urgent]

    Hi all, I have two little "problems":
    1. I would like to use only three decimals in a double, for example:
    double d = 3.142345;
    Here I would like d to be 3.142
    I know that I have to use NumberFormat and setMaximumFractionDigits(3) but I forgot exactly how. How is it done?
    2. How can I change decimal separator (.) to (,) for example:
    3.142 into 3,142 ?
    Thanx in advance

    Holy crud - I better hurry and answer this...
    1. I would like to use only three decimals in a
    double, for example:
    double d = 3.142345;
    Here I would like d to be 3.142
    DecimalFormat df = new DecimalFormat("0.000");
    System.out.println(df.format(d));>
    2. How can I change decimal separator (.) to (,) for
    example:
    3.142 into 3,142 ?
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    dfs.setDecimalSeparator(',');
    DecimalFormat df = new DecimalFormat("0.000", dfs);
    System.out.println(df.format(d));>
    Thanx in advanceHTH :o)

  • I cant get information about security questions . How to get it back

    Security question . I cant reset the information . About it . How to get the answer or how to change it .

    Security questions:
    https://discussions.apple.com/docs/DOC-4551
    http://support.apple.com/kb/HT5312
    http://support.apple.com/kb/HT5665
    If you don’t know your security questions, phone Apple (using the number listed here:  http://support.apple.com/kb/HE57  ) and ask for the Account Security Team.
    About 2-step verification of your Apple ID:
    http://support.apple.com/kb/ht5570
    This is also useful:
    http://www.macworld.co.uk/ipad-iphone/news/?newsid=3463233&olo=email

  • Vagueness about a question

    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=303&p_certName=SQ1Z0_146
    Why the correct answers for the last question are BC, and not BD? Why also C? Because if we change the value for the parameter PLSQL_CODE_TYPE to INTERPRETED from the previously set value of NATIVE, then for all PL/SQL program units that were compiled as native, subsequent automatic recompilations would use interpreted compilation

    Srini - I may be the cause of this confusion. This is the same OP that ask this question - Re: plsql_optimize_level and plsql_code_type
    See my post there and the other question that was ask. The other question involved PLSQL_OPTIMIZE_LEVEL; this question doesn't change the level.
    The OP may be trying to reconcile my response there (about a different question) with this new question.
    It would help if you would explain how to reconcile the reference you gave in the database reference:
    >
    If a PL/SQL library unit is compiled native, all subsequent automatic recompilations of that library unit will use native compilation.
    >
    With the quote I used to answer the other question which was in the SQL Reference for 11R2 (PL/SQL Units and Compilation Parameters - http://docs.oracle.com/cd/E11882_01/appdev.112/e17126/overview.htm)
    states:
    >
    If the optimization level (set by PLSQL_OPTIMIZE_LEVEL) is less than 2:
    •The compiler generates interpreted code, regardless of PLSQL_CODE_TYPE.
    >
    Are you saying that once the optimization level is 2 or more you can never recompile a currently compiled package as INTERPRETED? Or are you saying that it will never be AUTOMATICALLY recompiled as INTERPRETED but can be manually recompiled as INTERPRETED?
    If so then this would mean there is a difference between 'automatic' recompilation and 'non-automatic' (manual?) recompilation? Are there any other differences? Does that mean that automatic recompilation will not take 'conditional compilation' parameter settings into account?

  • Suspicious about 'security questions'

    I'm in China and have successfully downloaded a number of apps from the store, I recently downloaded an app from a Chinese developer (coincidence?) and now I can't download any others. I enter my password and get told to enter and answer 3 security questions to verify my ID. I know I only had 1 question when I set up my Apple ID and I have checked my details by logging into 'Manage My Account'. I am concerned that this is a bogus message and the request does not match with my details. Has Apple got security issues in China? Could my phone have been accessed in some way by someone and they are fielding my personal details/log in information? Anyone had anything simila? I can't contact Apple using the express line because they need to call me in China and their website wants to change all my details to Chinese - which I can't read. Does anyone know if Apple ask for details in this way normally? Does anyone know an email address I can contact Apple directly on?

    Thank you Roger. I was so worried it was a phishing scam or something that I stayed up late doing various searches on this site and stumbled across more than one thread about this problem.
    It would have stopped me and a lot of people from getting worried if Apple had told us they were implementing this new security layer. I understand they're trying to protect us, but what a strange way of going about it.
    Come on Apple, you design technology for communication purposes, so communicate effectively.
    Thanks again Roger.

  • I was not aware about security questions.. My account got locked for 8 hours. Is there a way to change those security questions to prevent problems in the future. Thanks

    Please help me to reset my security questions

    Read this about how to change the security questions: http://support.apple.com/kb/HT5312
    If you can't use these procedures contact Apple. See: http://www.apple.com/support/itunes/contact/

  • About OCA question

    Hi guys,
    i'm going to make the OCA exam next month.
    If a question like this appear, what would be the correct answer ?
    Question: A table name can never be composed starting with number. Is it correct ?
    what would be the correct answer, if we can have a table name with number, since this name is enclosed in double quotation marks ( " " ) ?
    thanks

    Hi,
    For the exam, remember of the rules for nomination of tables and columns:
    (1) Must be initiated by a letter
    (2) Must have of 1 up to 30 characters
    (3) Must only contains A..Z, a..z, 0..9, and special characters like _, $, # only
    (4) Should not to be a private word of the Oracle
    Take a look on these examples below:
    SQL> create table order (cod number);
    create table order (cod number)
    ERROR at line 1:
    ORA-00903: invalid table name
    SQL> create table example (
      2  id# number primary key,
      3  order$ number not null,
      4  date_1 date default sysdate,
      5  column2 varchar2(5),
      6  "cust_id" number);
    Table created.
    SQL> desc example
    Name                                      Null?    Type
    ID#                                       NOT NULL NUMBER
    ORDER$                                    NOT NULL NUMBER
    DATE_1                                             DATE
    COLUMN2                                            VARCHAR2(5)
    cust_id                                            NUMBER
    SQL> create table "hi! are you ok?" (cod number, "12345" number);
    Table created.
    SQL> desc "hi! are you ok?"
    Name                                      Null?    Type
    COD                                                NUMBER
    12345                                              NUMBERNow, about "double quotes", I think that OCA exam just want to test whether you know about the rules for nomination of tables and columns.
    Good Luck!
    Cheers

  • One of my kids submitted their friends email as our verification email if anything needs changed so now I am not getting emails about my questions.  I can not figure out where to find it to edit it

    Somehow my security answers are not correct.  So, I submitted to have the answers send to me and they are going to another e-mail address that I don't have access to.  I can't find it in my account to edit it though.  Anyone know where I can find it to change it?

    From a Kappy  post
    The Three Best Alternatives for Security Questions and Rescue Mail
       1. Use Apple's Express Lane.
    Go to https://expresslane.apple.com ; click 'See all products and services' at the
    bottom of the page. In the next page click 'More Products and Services, then
    'Apple ID'. In the next page select 'Other Apple ID Topics' then 'Forgotten Apple
    ID security questions' and click 'Continue'. Please be patient waiting for the return
    phone call. It will come in time depending on how heavily the servers are being hit.
    2.  Call Apple Support in your country: Customer Service: Contact Apple support.
    3.  Rescue email address and how to reset Apple ID security questions.
    A substitute for using the security questions is to use 2-step verification:
    Two-step verification FAQ Get answers to frequently asked questions about two-step verification for Apple ID.

  • Support about two questions.

    Want support about how remove or know two question I was forgetting and long time? Please help me

    The same reply applies as I posted in your duplicate thread : https://discussions.apple.com/message/22254189#22254189
    If you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then you can try going to https://appleid.apple.com/ and click 'Manage your Apple ID' on the right-hand side of that page and log into your account. Then click on 'Password and Security' on the left-hand side of that page and on the right-hand side you might see an option to send security question reset info to your rescue email address.
    If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then see if the instructions on this user tip helps you get them reset : https://discussions.apple.com/docs/DOC-4551

  • About security question

    hi there!
    i had sent reset my security question many time to my email!
    i have check in my email but nothing!
    please resolve early because i need buy something!
    thanks you!

    We are fellow users here on these forums, you're not talking to iTunes Support nor Apple
    If you haven't receved the email, and you've checked the spam folder as well as the inbox, then you will need to contact iTunes Support / Apple in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699

  • HT5312 It's keeping ask me about security question answer  and never add a security questionnaire how it's that possible?

    Hi a when I want to install a application it's keep ask me about answer a security question and I never add a security question. Thank you for you answer

    If you log into your account via http://appleid.apple.com, and select the Password and Security section on the left-hand side of that page are you able to set them ?
    If not, then from http://support.apple.com/kb/HT5665 :
    If you have three security questions and a rescue email address, sign in to My Apple ID and select the “Password and Security” tab to send an email to your rescue email address to reset your security questions and answers.
    If you have one security question and you know your Apple ID password, sign in to My Apple ID and select the “Password and Security” tab to reset your security question.
    If you have one security question, but don't remember your Apple ID password, contact Apple Support for assistance. Learn more about creating a temporary support PIN to help Apple confirm your identity when you contact Apple Support.
    If you can’t reset them via the above instructions (you won't be able to add a rescue email address until you can answer your questions) then you will need to contact iTunes Support / Apple in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down this page to add a rescue email address for potential future use : http://support.apple.com/kb/HT5312

  • About license question

    HI All
    Now I have a POC lab and the trail license expired. but user seem could login and access their files...
    I want to ask about trail licnese expired...what actions could not perform ?
    about I have a potenial customer...he want to buy less count (about 50 users)...but he ask me if user more than 50 (ex:want to make 60 users)..
    Q1: whether the license files need upgraded or not ?
    Q2: if Q1 answer is "Yes, need replace another new license file", Filr will block new user login (more than 51 users account session) when using old license ?
    thanks!!
    wyldkao

    Originally Posted by jmarton
    sctlam wrote:
    > But how can one ensure the total number of license in use ? That 's
    > the reason for my questions.
    The activity reports will show you how many users are using Filr.
    However, licenses in use = # of users imported via LDAP as far as audit
    tools are concerned. Even if not all of those users are using Filr,
    they must still be licensed. If you want to limit the # of licenses
    you need to use LDAP filters to limit the # of users imported.
    Thanks for you reply.
    "License Report" should show both users imported via LDAP and other means (e.g. only defined in Filr or self register).
    There are several counters in that report. Namely, "Current active user count" and "User in past 365 days". Observed these figures are identical. I was also told that one should use the former to determine whether purchased license is enough. Observed these two figures did not change even if one deleted or disable IDs. Not sure whether this is the expected behavior.

Maybe you are looking for

  • ICloud storage for new photos app

    iI've just updated Yosemite and the new photos app is asking me to upgrade my storage, now if I do this will it upload all my photos on my iMac to the cloud including external drives connected to my iMac?

  • Still unable to sync calendar from Outlook with iPhone 2.0.1 / 7.7.1.11

    I have an older non-3G iPhone which worked fine on sync’ing with Outlook2007 running on my Vista laptop. Then the upgrades to 2.0 and 7.7 came through automatically, and ever since sync’ing just doesn’t work..... Leaving aside all the problems that I

  • Book module LR 5.7 adding photos and putting text in spine

    I'm creating a book in the book module of Lightroom. I imported photos from a collection and used auto layout. I wish to add two more photos. I've added them to the collection, but I can't add them to the book I'm creating. i haven't yet clicked on c

  • Illegal start to expression - java applet

    Hi Guys, this code is for a hangman game which will be in an applet. When I try putting the buttons in init, I'm getting an "illegal start of expression" for each button. Can someone tell me what I'm doing wrong? Cheers, * @(#)Hangman.java * Sample A

  • EJBLocalHome - ClassCastException

    In our application we are caching the EJBLocalHome in a HashMap. The code for caching is in the server's classpath and all the EJB's and other webapp's deployed in a single WAR uses this ServiceLocator to get the cached EJBLocalHome. Intermittantly w