How is it possible to precise a float number in java

Hello ,
It is my second post and i couldnt find an answer to it. The problem ii want to display a float number with only the last three decimal after the comma. For example, float x = 23.445566 and i need to display only 23.445
How can i do that ? here is the code:
int val1 = 1432;
int val2 = 13;
float result = 0.000F
(float) (valu1/valu2)
the result = 110.153846...
And what i want to display is 110.153
Please help.
Thanks

You're right - java.text.Decimal format uses round half even, java.util.Formatter uses round half up.
    Float f = 0.5F;
    System.out.printf("%.0f\n", f);
    System.out.println(new java.text.DecimalFormat("0").format(f));
1
0In the ASNI C implementations I've worked with, printf also uses half-even.
Bizarre.
Pete

Similar Messages

  • How to get the amplitude of a sound as a float number in Java

    Hi, I would like to create a program which plays an audio file(it may be a midi, probably) and it returns
    the amplitude of the sound in terms of float number.
    I mean, is it possible to obtain this number, since every sound file is actually a sequence of float number like
    110.010110101 etc.
    Can you help me with suggestions and details about the way to take.
    Regards
    Frank

    For sampled sound, the answer might be seen in [ this thread|http://forums.sun.com/thread.jspa?messageID=10636576#10636576]. For MIDI it is different in that you will only be able to get it as sampled sound once it has been synthesized, and as I recently found out, to get the audio coming through the regular sound lines will take nothing less than a physcical or software 'audio loopback' being installed, on most PCs.
    Of course, if it is MIDI, you might just cheat by calculating a 'volume' from the note velocities in the MIDI score.

  • How can I get the orclownerguid (unique user number) in Java Portlet?

    Hi,
    I find a unique number for each portal user in OID, it calls orclownerguid.
    And I try to obtain this number in my portlet Java with the JPDK.
    How can I get the orclownerguid in Java Portlet with JPDK?
    thanks
    regards
    jerome laforge

    Hello,
    I just realized that I missunderstood your question.
    We have several way to pass (and send) parameter to a portlet:
    - OracleAS Portal page parameters that allow the browser user to define the way the parameter is send to the portlet
    - generic URL parameter (public parameters)
    - private paramter (a parameter that is targetted to a single portlet instance)
    In you case, you can use public parameter, but you have to explicitly says that your portlet consume URL parameters, so set the passAllUrlParams tag to true in the provider.xml file.
    Also I invite you to read the sample we have in the PDK that show how to use private parameter and page/portlet parameters, and the associated articles you can find on http://portalstudio.oracle.com
    Regards
    Tugdual Grall

  • Precision with float and double values

    Hi, does anyone knows how can i get more precise calculations with floating point numbers? Let's see an example:
    public class Teste {
    public static void main(String args[]) {
    float i = 0;
    while (i<=10) {
    System.out.println(i);
    i=i+0.1f;
    /* output
    0.0
    0.1
    0.2
    0.3
    0.4
    0.5
    0.6
    0.70000005
    0.8000001
    0.9000001
    1.0000001
    1.1000001
    1.2000002
    1.3000002
    1.4000002
    1.5000002
    1.6000003
    1.7000003
    1.8000003
    1.9000003
    2.0000002
    2.1000001
    2.2
    2.3
    2.3999999
    2.4999998
    2.5999997
    2.6999996
    2.7999995
    2.8999994
    2.9999993
    3.0999992
    3.199999
    3.299999
    3.399999
    3.4999988
    3.5999987
    3.6999986
    3.7999985
    3.8999984
    3.9999983
    4.0999985
    4.1999984
    4.2999983
    4.399998
    4.499998
    4.599998
    4.699998
    4.799998
    4.8999977
    4.9999976
    5.0999975
    5.1999974
    5.2999973
    5.399997
    5.499997
    5.599997
    5.699997
    5.799997
    5.8999968
    5.9999967
    6.0999966
    6.1999965
    6.2999964
    6.3999963
    6.499996
    6.599996
    6.699996
    6.799996
    6.899996
    6.9999957
    7.0999956
    7.1999955
    7.2999954
    7.3999953
    7.499995
    7.599995
    7.699995
    7.799995
    7.899995
    7.9999948
    8.099995
    8.199995
    8.299995
    8.399996
    8.499996
    8.599997
    8.699997
    8.799997
    8.899998
    8.999998
    9.099998
    9.199999
    9.299999
    9.4
    9.5
    9.6
    9.700001
    9.800001
    9.900002
    */

    http://forum.java.sun.com/thread.jsp?forum=31&thread=357174

  • How is it possible to use Index Seek for LIKE %search-string% case?

    Hello,
    I have the following SP:
    CREATE PROCEDURE dbo.USP_SAMPLE_PROCEDURE(@Beginning nvarchar(15))
    AS
    SELECT * FROM HumanResources.Employee
    WHERE NationalIDNumber LIKE @Beginning + N'%';
    GO
    If I run the sp first time with param: N'94', then the following plan is generated and added to the cache:
    SQL Server "sniffs" the input value (94) when compiling the query. So for this param using Index Seek for AK_Employee_NationalIDNumber index will be the best option. On the other hand, the query plan should be generic enough to be able to handle
    any values specified in the @Beginning param.
    If I call the sp with @Beginning =N'%94':
    EXEC dbo.USP_SAMPLE_PROCEDURE N'%94'
    I see the same execution plan as above. The question is how is it possible to reuse this execution plan in this case? To be more precise, how
    Index Seek can be used in case LIKE %search-string% case. I expected that
    ONLY Index Scan operation can be used here.
    Alexey

    The key is that the index seek operator includes both seek (greater than and less than) and a predicate (LIKE).  With the leading wildcard, the seek is effectively returning all rows just like a scan and the filter returns only rows matching
    the LIKE expression.
    Do you want to say that in case of leading wildcard, expressions Expr1007 and Expr1008 (see image below) calculated such a way that
    Seek Predicates retrieve all rows from the index. And only
    Predicate does the real job by taking only rows matching the Like expression? If this is the case, then it explains how
    Index Seek can be used to resolve such queries: LIKE N'%94'.
    However, it leads me to another question: Since
    Index Seek in
    this particular case scans
    all the rows, what is the difference between
    Index Seek and Index Scan?
    According to
    MSDN:
    The Index Seek operator uses the seeking ability of indexes to retrieve rows from a nonclustered index.
    The storage engine uses the index to process
    only those rows that satisfy the SEEK:() predicate. It optionally may include a WHERE:() predicate, which the storage engine will evaluate against all rows that satisfy the SEEK:() predicate (it does not use the indexes to do this).
    The Index Scan operator retrieves
    all rows from the nonclustered index specified in the Argument column. If an optional WHERE:() predicate appears in the Argument column, only those rows that satisfy the predicate are returned.
    It seems like Index Scan is a special case of Index Seek,
    which means that when we see Index Seek in the execution plan, it does NOT mean that storage engine does NOT scan all rows. Right?
    Alexey

  • Quick Camera - how is this possible?

    I noticed a new app in photography category called "Easy Camera". It takes pictures super fast in low resolution (320x480). I tried out the app, and it can take 2-3 pictures per second. The app requires OS 2.2.1.
    Does anybody know how this is possible? What feature/code is the developer accessing to make this happen?

    From the Data Sheet:
    CISCO 1000BASE-LX/LH GBIC
    The Cisco 1000BASE-LX/LH GBIC (WS-G5486) fully complies with the IEEE 802.3z 1000BASE-LX standard. However, its higher optical quality allows it to reach 6.2 miles (10 kilometers) over single-mode fiber (SMF), compared with the 3.1 miles (5 km) specified in the standard.
    CISCO 1000BASE-ZX GBIC
    The Cisco 1000BASE-ZX GBIC (WS-G5487) operates on ordinary single-mode fiber optic link spans up to 43.4 miles (70 km) long. Link spans of up to 62 miles (100 km) are possible using premium single-mode fiber or dispersion shifted single-mode fiber. The GBIC provides an optical link budget of 23 dB-the precise link span length will depend on multiple factors such as fiber quality, number of splices, and connectors.
    When shorter distances of single-mode fiber are used, it might be necessary to insert an in-line optical attenuator in the link to avoid overloading the receiver:
    NOTE: A 5-dB or 10-dB inline optical attenuator should be inserted between the fiber-optic cable plant and the receiving port on the Cisco 1000BASE-ZX GBIC at each end of the link whenever the fiber-optic cable span is less than 15.5 miles (25 km).
    It looks like they both work OK with SM fiber.
    LX is 1310 and ZX is 1550 which is also OK since (most) all Cisco RX optics are wide-band.
    One thing you might check is the RX power to make sure the leves are within the spec.
    http://www.cisco.com/en/US/prod/collateral/modules/ps5455/ps6577/product_data_sheet09186a008014cb5e_ps872_Products_Data_Sheet.html

  • Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?

    Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?

    If you just installed iCloud does that mean you updated the iOS that's running on your iPad?  If so, you'll want to restore all the programs you have from the backup you hopefully made.
    Refer to these articles for help.
    iTunes: Backing up, updating, and restoring iOS software.
    If you don't want to use iCloud, simply don't activate it.
    You can also download the programs again.
    If you live in a country that supports re-downloading apps then you can re-download them.  You can refer to this article for more help.
    Downloading past purchases from the App Store and iTunes Store
    What to know if your country supports downloading past purchases?
    iTunes in the Cloud Availability

  • I just bought my macbook pro and it's charged up to 100% and is still plugged in but now shows the battery at 98%.  How is this possible when it's plugged in to the charger and the green light is on?

    I just bought my macbook pro and it's charged up to 100% and is still plugged in but now shows the battery at 98%.  How is this possible when it's plugged in to the charger and the green light is on?

    The system regularly lets the battery drop to about 95% when on the charger, then recharges to 100%.  This lets the batery exercise "just a little" all of the time and saves the recharge curcuits from overuse.
    Regualr occurence for me.
    Also ... you need to let your battery work at least once per month.  Let it run down to 40%, but not less if you can at all avoid it.  Running thr battery fully dead will shorten the battery life significantly.

  • Mini Display to VGA adapter stopped. The Mini Display to HDMI is still working fine. How´s that possible?

    The mini display to VGA adapter had stopped, whinle the Mini Display to HDMI keeps working fine. The minid display to VGA adapter was replaced and the VGA cable as well, and the problem is the same. This test was made with two diferent monitors with VGA entries. How´s that possible to happen? Is that a configuration trouble in the MBP?

    The Apple´s customer support gave us the solution for this problem:
    SMC reset
    PRAM reset
    The VGA adapter return to work properly aflter this procedure.

  • I want to buy a Ipod Nano 16gb and it says it holds up to 4,000 songs, and 16 hours of video but on my Itunes I have 2,593 songs and it says I have 19.88 gb. How is this possible?

    I want to buy a Ipod Nano 16gb that says it holds up to 4,000 songs, 16 hours of video, and 14,000 pictures. On my Itunes Library, I have 2,593 songs and it says I have 19.88 gb just of songs. How is this possible? If I buy the Nano, will I not be able to have all my songs on the ipod? The music is my first and only prioarity. I want to be able to have up to at least 3,000 songs, even if that means not having video or pictures. Can someone please help me?

    Daniella04 wrote:
    I want to buy a Ipod Nano 16gb that says it holds up to 4,000 songs, 16 hours of video, and 14,000 pictures. On my Itunes Library, I have 2,593 songs and it says I have 19.88 gb just of songs. How is this possible? If I buy the Nano, will I not be able to have all my songs on the ipod? The music is my first and only prioarity. I want to be able to have up to at least 3,000 songs, even if that means not having video or pictures. Can someone please help me?
    Daniella,
    The estimated song capacities, such as 4000 songs in 16 GB, are based on 4 minute songs of 4 MB each, which is what you get at 128 encoding. 
    Most of us nowadays use well above 128.  (For example, the iTunes Store and Amazon MP3 both sell songs only in 256.)
    However, you can still make more songs fit!  When you sync your iPod, use the option to "convert higher bit rate songs," as pictured.  Choose 128.  This fits more on the iPod, but does not change the songs in your library.

  • HT5570 My six-year old grandson appears to be able to make purchases on the TV without having to enter the password and yet every other device i use (e.g. iPad, iPhone, iPod) is password protected. How is that possible?

    My six-year old grandson appears to be able to make purchases on the TV without having to enter the password and yet every other device i use (e.g. iPad, iPhone, iPod) is password protected. How is that possible when I have to use my password to access such services on all other devices?

    DominicDeBurca wrote:
    My six-year old grandson appears to be able to make purchases on the TV without having to enter the password and yet every other device i use (e.g. iPad, iPhone, iPod) is password protected. How is that possible when I have to use my password to access such services on all other devices?
    Having AppleTV remember the password is optional.
    Logout of iTunes store, log back in and hopefully next time you come to purchase you'll be prompted for your password but decline the option to remember it.  You might also want to look out of parental controls on the unit.
    AC

  • Using Maverick, how is it possible to open more than one calendar window?

    Hi, I'm using Maverick 10.9.1
    My question is: how is it possible to open more than one calendar window? i would like to have on the right my personnal calendar dates and on the left, my company calendar.
    Many thanks in advance for your help!
    ph

    See if the section on group calendar helps.
    http://www.dummies.com/how-to/content/basics-of-calendar-in-os-x-mavericks.html

  • When i send a text message with my new iphone 5 to my wife who is now using my old Iphone 4 we both receive the message. How is this possible? Also she receives all text messages sent to me

    when i send a text message with my new iphone 5 to my wife who is now using my old Iphone 4 we both receive the message. How is this possible? Also she receives all text messages sent to me. She obviously has a different phone number and a different provider

    See here to create a new apple ID
    http://support.apple.com/kb/HE37
    good luck

  • I have an ipad and iphone sharing icloud.  The ipad is using 268mb, the iphone 2.6.  My plan is 5gb but it keeps saying I don't have enough space to back them up.  How is this possible?

    I have an ipad and iphone sharing icloud.  The ipad is using 268mb, the iphone 2.6.  My plan is 5gb but it keeps saying I don't have enough space to back them up.  How is this possible?

    Hey sameyrs2,
    Thanks for the question. Based on what you stated, it seems like you are getting a message when trying to backup to iCloud. I would recommend that you read these articles, they may be helpful in troubleshooting your issue.
    iCloud: Understanding Backup alert messages
    Manage your iCloud storage
    Thanks for using Apple Support Communities.
    Cheers,
    Mario

  • Lost Mode and Play Sound are "Pending."  However, iCloud indicates that it connected and backed up to iCloud at a date that is 1 week after it went missing.  How is this possible without locking (Lost Mode Pending an internet connection)

    Hi,
    My wife lost her iPhone two weeks ago while on vacation in London (cell service inoperative in foreign country).  Using Find My iPhone app on my device, I activated Lost Mode and Play Sound.  However, both are listed as "Pending," since it those actions require the phone to connect to the internet (wifi only due to no cellular data coverage.).
    We recently returned home and purchased a new iPhone.
    However, when looking to restore the apps/settings from her old phone using a previous iCloud backup, iCloud indicates that the old phone connected to iCloud and backed up the original phone at a date that is 1 week after it went missing.  How is this possible without locking (Lost Mode Pending an internet connection)?
    If the phone was activated and connected to the internet via a wifi signal, shouldn't it immedately lock, show up on the map, Play Sound, and send me an email that the phone has been found?
    I also read somewhere that if running iOS 7, the iCloud website interface enables you to track previous locations, for instance if the phone moves from wifi hotspot to hotspot.  Is that true?  If so, how do I do that?
    Thank you for your time, and have a great day!
    Sincerely,
    - Matt

    just giving this a wee bump as time is of the essence here and i need advice/ answers quick!
    apologies if i've broke any rules!
    alex

Maybe you are looking for

  • Logic pro 9 won't open

    When i try to launch logic pro it says the following,my software is version 10.7.2 Process:         Logic Pro [1545] Path:            /Applications/Logic Pro.app/Contents/MacOS/Logic Pro Identifier:      com.apple.logic.pro Version:         9.0.0 (16

  • Takes Long time for Data Loading.

    Hi All, Good Morning.. I am new to SDN. Currently i am using the datasource 0CRM_SRV_PROCESS_H and it contains 225 fields. Currently i am using around 40 fields in my report. Can i hide the remaining fields in the datasource level itself (TCODE : RSA

  • Can I stop iTunes from downloading the SD version when I purchase HD Video?

    When I order the HD versions of a program, my computer shows both a standard and HD version on the Downloads list, and tries to download both of them. Also, shows that I have deleted keep re-appearing and trying to re-download whenever I launch iTune

  • Only headers and footers appear attempting to print PDFs in Safari 5.0.2

    I am a Mac user trying to help my friend, who uses Safari 5.0.2 on his PC. He can open PDFs within Safari, but when he attempts to print them, all that appears are headers and footers (same thing appears in Print Preview). Any suggestions?

  • Task Flow Clues!

    Hello there, i need a to achieve this: First 2 task flows one for Menus and the other for Process. On the first task flow there's only a page fragment that contains 4 command buttons, each button sends a parameter to the other task flow. The second t