How to format floats (or doubles ) but not converting to String?

Hi everybody,
my question is simple:
I have a number,lets say 51,4567321 and i want to format it ,as a float or double ,as 51,45.
One way is to do:
float x=((hits * (float) 100) / this.getAccesses());
DecimalFormat perCentFormatter = new DecimalFormat("00.00");
String formattedNum=this.perCentFormatter.format(x);and that will create a string "51,45".
But how do i do to create a float or double or anything else that holds the value with 2 decimal points after mantissa?e.g XX,XX
Thank you very much,
Chris

A few options:
1) just live with it. The float and double formats hold their values in binary, you know, and you only have approximations of multiples of tenth and one-hundreds of unity. It's all just approximations for those types. C'est la vie.
2) Use java.math.BigDecimal, which gives you control over rounding.
3) Change your design, so you use integers with the lower unit. So if the float currently "51,23" represents 51 Euros and 23 cents (what's the word? Europennies?), then you'd use an int of 5123 to represent five thousand one hundred and twenty-three cents.

Similar Messages

  • I am at capacity How can I free up space but not delete music

    My Ipad is at 55.4 gb used 24 gb in music alone. 2.7 gb available so can't do anything  Ipad shuts itself down and won't let me open mail, use facebook, safari.How can I free up space but not delete songs in library   

    Unless you are attempting to download a sizable file, 2.7 GB should be more than enough to continue fucntioning. Try a reset: Simultaneously hold down the Home and On buttons until the device shuts down. Ignore the off slider if it appears. Once shut down is complete, if it doesn't restart on it own, turn the device back on using the On button. In some cases it also helps to double click the Home button and close all apps from the tray BEFORE doing the reset.

  • How do I configure thunderbird open but not jump to web link in e-mail

    How do I configure thunderbird open but not jump to web link in e-mail. I want the web pages, but do not want to display my browser page until I have clicked on several links, then I will go look at my browser pages.
    I can't figure out how to do this.
    Thanks,
    Dan

    From the menu bar select Tools-Account Setting-Composition and Addressing
    Set the reply option to Above the Quote
    You have to do this for each account if you have more than one.
    No menu bar? Press the alt key.

  • How do I loop my images but not my music?

    How do I loop my images but not my music in iDVD 08?

    Give it a litte time.. Then
    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • Aperture adds the same name to all new locations, how do I delete the name but not the address?

    Aperture adds the same name to all new locations, how do I delete the name but not the address?

    It's easy to rename each unit.  When you connect your iPad and it syncs, the unit will appear on the left of the iTUnes screens just click on the unit there and you can rename it.  You should do this immediately so you can see which unit was backed up by it's name. You can sync as many decices as you want in one iTunes library and you can even share Apps as long as you're going to sync both from teh same iTunes account.  My household has 2 iPad 2s and we share our apps, and we also share downloaded books, magazines, music, etc.......

  • How could i get other themes  but not in keynote, How could i get other themes  but not in keynote

    How could i get other themes  but not in keynote???!!!

    Create them yourself, specific, simple, easy and free.

  • How can I tell with % how fast I am uplaoding a file...I know how to find it for DOWNLOADING, but not uploading.

    I just switched to Firefox...I used to have Google Chrome...when I would upload a file, a % number would scroll at the bottom showing me how much has been uploaded....how do I find that on Firefox....I know how to find the DOWNLOAD box, but not one for UPLOADING opr sending files

    I mistyped in my first post. I do indeed mark the video as AF41 (Cos4). It is the call control that I mark CS3 with the policy map to get around the old Tandberg bug that doesn't mark the call control.
    So do you think the queue 3, where Cos4 goes to, is big enough to handle 30 video streams of 480k? If my calculation is correct that would be 14.4mbps of video on a 100mbps port.
    With this config.....
    srr-queue bandwidth share 10 10 60 20
    srr-queue bandwidth shape 10 0 0 0
    ...is it telling me that queues 1 & 2 get 10% bw, queue 3 gets 60% and queue 4 gets 20% bw and is shared? If that is correct than 60% is more than enough for 14.4mbps of video.
    What happens if too much video overruns the queue?

  • After "upgrade" to new firefox, bookmarks didn't transfer. Help tells how to import from another browser but not old firefox. Also my anti virus (latest update) apparently not compatible with 4.0 Can I restore my old version

    Question
    After "upgrading" to new firefox none of my bookmarks are in new bookmarks help topics tell me how to import from another browser but not from previous version of firefox. Another problem is my anti virus ( most up to date) is apparently not compatible with 4.0 liked the old firefox would never have "upgraded" had I known my anti virus wouldn't work. Can I get old version back

    Check with Kaspersky as to what versions of Firefox their programs are compatible with. It is up to Kaspersky to keep their stuff up to date as Mozilla releases new versions of Firefox. And if they are unwilling or incapable of doing it, they should inform their customers of such and maybe refund their customers instead of stringing them along.
    http://forum.kaspersky.com/

  • How to Delete document from Item but not Item itself

    Hello
    I'm working on Oracle Portal (10g)
    I'm thinking about one problem:
    - how to physically remove document form the Oralce repository using PL/SQL
    Does removing row from WWDOC_DOCUMENT$ remove file from hard disk (some
    trigers on Delete?).
    BTW:
    There is one strange (for me ;) ) behavior: I create an item with atached
    file (file item) what happent:
    - in table WWDOC_DOCUMENT$ is new row for new file created.
    - in table WWV_THINGS$ is new row for new item created
    Now I would like to remove file but not item (still using PL/SQL).
    I use function for example:
    PORTAL.Wwdoc_Api.remove_document('101801.BMP');
    This function remove path id and filename but not whole file row itself (but
    this is less problem). And othere more important problem: after
    PORTAL.Wwdoc_Api.remove_document called there is still in item rows pointer
    to just deleted file in fields: FILENAME and VALUE.
    I would like to set this fileds to null. - in othere way there is exception
    durring page deletion (no document found).
    I use:
    update portal.wwv_things p1
    set
    p1.FILENAME = null,
    p1.VALUE = null
    where p1.ITEMTYPE like 'basetext'
    and p1.LANGUAGE = wwctx_api.get_nls_language
    and p1.SITEID = pagegroupID
    and p1.CORNERID = pageID
    and p1.filename like '101801.BMP' ;
    But this seems to not work at all.
    Any body else had some problems like me?
    How it was solved.
    BTW: I work with item versioning.
    BIG THANKS YOU FOR ANY HELP

    You can try my new DeDupe script. It should be able to get rid of the redundant copies while keeping one copy of each track in each format. See this thread for background.
    I've not used the feature, but iTunes can downsample to 128k AAC on the fly as it syncs your devices. Of course you might find the process is too slow for your needs or find that 128k is too much compression.
    tt2

  • How to delete duplicates from iTunes but not hard drive

    I'm running iTunes 10 and have my music stored on both my NAS drive and backup drive.  Each track appears twice on iTunes: once as lossless for streaming and and once as compressed AAC files for synching to ipods and iphones.
    For some reason, when my PC is turned on after being turned on, the linkstation cannon be 'seen' by iTunes, and therefore if I try to play a track, 'the original file cannot be found'.  If I use the 'add folder to library' option in the 'file' dropdown menu, the tracks are located again.
    Unfortunately, I the last time I did this it resulted in 4 copies of each song on itunes; 2 lossless and 2 AAC.
    I have 2 questions:
    Firstly is there an easy way to delete the duplicates from my iTunes library so that I am left with only 1 lossless and one AAC copy, but not deleing the files from my NAS and backup drive?
    Is there a way I can just store my music as lossless, but convert it easily to aa more compressed format for synching to iphone and ipod?
    Thanks!

    You can try my new DeDupe script. It should be able to get rid of the redundant copies while keeping one copy of each track in each format. See this thread for background.
    I've not used the feature, but iTunes can downsample to 128k AAC on the fly as it syncs your devices. Of course you might find the process is too slow for your needs or find that 128k is too much compression.
    tt2

  • How to make a rollover image, but not for a button

    Hello,
    I should probably not care so much about this, but I'm
    wondering how to make an image have a rollover state without making
    it a clickable button. See the link below, and when it all loads,
    move your mouse over the "go home" button at the bottom. I'd like
    for that rollover to happen but without the little "link hand"
    showing up, you know? I know how to do this in html but I'm new to
    flash so I'd love it if somebody here could help me out. Thanks!
    Here's the link:
    http://www.designedbytim.com/flash/

    holycrap its tim wrote:
    > Hello,
    > I should probably not care so much about this, but I'm
    wondering how to make
    > an image have a rollover state without making it a
    clickable button. See the
    > link below, and when it all loads, move your mouse over
    the "go home" button at
    > the bottom. I'd like for that rollover to happen but
    without the little "link
    > hand" showing up, you know? I know how to do this in
    html but I'm new to flash
    > so I'd love it if somebody here could help me out.
    Thanks!
    >
    > Here's the link:
    http://www.designedbytim.com/flash/
    >
    onClipEvent (load) {
    useHandCursor = false;
    i hope this works.
    Michael Katindig
    www.somnotikroom.tk
    \\ illustrator and multimedia designer //

  • How do I delete some history but not all without it crashing?

    I remember that Firefox used to allow deleting of only some history but not the most recent. For example, I was able to go into Options and under the Privacy tab, I could choose for Firefox to remember the last 7 days, 30 days, etc. Now, it seems that I can only choose "Remember history", "Do not remember history", and the custom option does not allow me to choose how long I want Firefox to remember the history while deleting everything else.
    When I press Ctrl-H to open up the history on the side, it shows all the history from a very long time. I remember I used to be able to right-click on a folder (say several months back) and delete it all. Now if I try to do the same thing, it takes a long time and essentially crashed.
    I do not know why these features were removed but Firefox is very difficult to use as a result of that now. Could you please help me out with this?
    Thanks.

    If you have problem with deleting the history in the Library then you can delete the places.sqlite file in the Firefox profile folder.<br />
    Note that this will remove all history (you can copy/paste or drag history items to a bookmarks folder).
    Problems with bookmarks and history not working properly can be caused by a corrupted places.sqlite database file.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    You can use this button to go to the Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    Current Firefox versions do not have a time limit for the history.
    Firefox determines automatically how many pages can be kept without affecting the performance.
    You can see the current value via the read-only pref places.history.expiration.transient_current_max_pages on the about:config page.
    See Marco Bonardo's blog about this:
    * http://blog.bonardo.net/2010/01/20/places-got-async-expiration
    *Expire history by days: https://addons.mozilla.org/firefox/addon/expire-history-by-days/

  • How to have a SFC active but not record labour??

    My latest challenge from the shop floor is how to have an SFC still be active without anybody being laboured onto it (Visiprise 4.2)
    We have several processes that require product to be placed in an oven for a long period of time, sometimes several days. Our production staff "sign on" to the SFC whilst they prepare the oven and load it. They then "sign off" and work on something else. When the process is completed someone (not always the same person) "signs on" to the SFC removes the product etc and the "completes" the operation.
    This gives us the actual labour touch time and the actual cycle time , the problem is that when the first operator signs off the SFC it changes it status back to "In Queue" which then show in the WIP reports as being available for work, which it isn't.
    So, is there anyway of signing off the SFC but  not changing status to "In Queue" ?? That way it will not show in the WIP reports as being available for work and will stop our operators getting so confused .
    Thanks for any help that you can give.
    Kev

    Kev,
    In any case you cannot have SFC in work but without any assigned user who is meant performing some actions over that SFC.
    You can create some "dummy" user account and start SFC with that user each time you start heating the unit in the oven. To take the unit out of the oven, the second operator will Labor On against the SFC and perform Complete.
    As another option, you can play with Special operation: create a router of one operation corresponding to the action of heating and use the same resource of the oven; the second step is Return(Next). Each time "dummy" user starts an SFC at the operation, the SFC will be taken out of work from the production router. When SFC is completed here by the second user after Labor On, the SFC should be returned to the next step of production router (though I have not tested this way of disposition).
    Anyway, such "cheating" with the basic functionality will be rather intricate - so you might consider requesting a customization.
    Regards,
    Sergiy

  • Lidswitch:How to just shutdown the screen but not hibernate the system

    I used to set HandleLidswitch = hibernate in /etc/systemd/logind.conf and when I close the lid, only the screen was turned off and everything went on in the system. So I can sit there waiting for the work done without being distracted from the flashing outputs of gcc.
    But after reinstalling the system(I made a stupid mistake), it seems that after HandleLidswitch is set to "hibernate", it completely shutdown the computer, which stick to the defination of hibernate, but not what I want.
    How can I get the good old feature back? Thanks in advance!

    You can set HandleLidSwitch=ignore and then set what you want with acpid.

  • How can i check for posted but not yet commited changes in a form

    Dears
    I make changes programmatically in a form then i post it using (Post built in).
    If the user exits the form, i make check for any changes in the form to commit it using the system variable :system.form_status
    Unfortunately the value of this system variable is 'Query' not 'Changed' because of using the post built in.
    Is ther another system variable ( or any another way ) that check for posted but not yet commited changes in the form ?
    Thanks a lot
    Mostafa Abolaynain

    I had faced similar situation. Using of package variable which identifies, what is the user's latest action.
    This is just a workaround.
    Capture what the user has performed into a variable say, PKG_VAR.ACTION,
    This will be assigned values like List L, and Create C, Update U and Saved S.
    If commit is executed,assing the status S to the variable.
    So while closing,
    IF :system.form_status = 'CHANGED' or PKG_VAR.ACTION in ('C','U') THEN     
    -- validate the data, n perform commit.
    else
    -- just close the form.
    end if;
    Regards
    Deepz : )

Maybe you are looking for

  • Can i share my purchases with wife,

    Hi, Both myself and my Wife have a Ipad and Iphone with our own account logon. is there anyway to share our content Movies/Music? I am aware of home sharing but this only works when you are on the network i am lead to believe. I work away alot i  wou

  • Reading value of bind variable

    Hi, I have been debugging a java application and in the process I wanted to know which values the application passed as bind variables. So i checked v$sql_bind_capture and enabled trace on the session. Unfortunately the datatype was TIMESTAMP, so the

  • Add Exists filter into Reporting Services MDX

    Hi, I have a piece of auto generated MDX which I need to filter. This was a generated by Reporting Services when I added a parameter to a report reading from a cube. WITH MEMBER [Measures].[ParameterCaption] AS [Dept].[DeptName].CURRENTMEMBER.MEMBER_

  • Master Data Mapping

    Hello Experts, I am in the process of designing an infocube and i was a little confused about the 2 char hierarchy and wanted to clear my confusion on it. In the flat file, we can have data either at account level or account group level. So i was thi

  • BP Creation with BOL

    HI All, My Requirement is: 1. Create New BP 2. Assign Marketing Attribute to it. 3. Create Relations with other BP's I am planning to use BOL Objects for this. if any body has any idea or done some thing similiar, please share your Ideas. I need to p