EPOS Java Number Rounding Problem

I am developing a java EPOS system and am having a strange issue with number accuracy that doesnt make any sense to me.
On a till system you have a user display of the form
0000000.00
When you type into this for example the number 7 then the number 8 it goes
0000000.07
0000000.78
Moving along the screen.
I cant figure out how to represent this accurately (ie using floats) but still have the functionality to append onto the float, not add to it.
i have come up with the following
        Float tempNum = currentNum*10;
        StringBuffer sb = new StringBuffer(tempNum.toString());
        sb.append(i);
        String s = sb.toString();
        currentNum = Float.valueOf(s).floatValue();
        updateOutputs();With the basic idea being casting to a string buffer, appending then casting back of sorts but i get accuracy issues...
Pressing 7 a whole bunch of times gives 7777.9995 not 7777.77 etc
I know there must be a simple and more elegant way to solve this problem but i just cant seem to think around it right now.
Thanks

This is an input panel on an EPOS system, but as im designing it for touch screen it has an on screen number pad and display of the number.
When the buttons are pressed for the numbers that number is appended to the internal integer storage value. Also the output string is updated.
Most till systems allow you to enter up to X digits until then ignore what you type or print an error, so i am happy to follow this behavior but require the digit count.
I hope that makes sense but if not my gui is similar to these...
http://www.tillrollshop.co.uk/asps/uploads/big/1205-1.jpg
http://www.mi-store.com/mi-store/Till_Main.jpg
The second image shows a number pad and label just like mine.
Thanks

Similar Messages

  • Strange number rounding problem

    I am using CR 8.5 and I have a number field inserted into the detail section of my report.
    Although rounding is set to 0.001 in the number format, the field displays rounded to the nearest whole number (e.g. 11.235 is displayed as 11.000). I have checked the field in the underlying tables and inserted the same field into another report without any problems.
    I've used different number formats in hundreds of reports without any problems, the only difference here is that the report was set-up by another user on another PC (but using the same version of Crystal).
    I suspect that rewriting the report from scratch would solve the problem, but I'd rather avoid this.
    Any suggestions?

    Hi
    Have you tried this:
    1. Right click on the field -> Format field -> Customize -> Rounding -> select the format that is required.
    Hope it helps!!!
    Regards
    Sourashree

  • Acrobat Pro 6 Average Daily Production and Math.round problem

    Acrobat Pro 6 Average Daily Production and Math.round problem
    (Production.0) (154) (whole units) . (Production.1) (90) (fractional) / (divided by) 31 (days) results in (Average.0) (4)(whole units) . (Average.1) (10) (fractional) using :Math.round.� Noticed that 154 (whole units) . 85 through 99 (fractional) also show 4.10. (without Math.round : 5.00)
    Method:
    �Production.0� (whole units) . �Production .1� (fractional) / Days = (Average Daily Production) (�Average.0� (whole units) . (Average.1) (fractional)
    � Production.0 (value not calculated)�, � Production 1 (calculated) (event.value = util.printx("0099", (event.value)).substr(-2,2); � �Average.0 (value not calculate)�, and �Average.1 has following calculation:
    var punits = this.getField("Production.0");
    var pfrac = this.getField("Production.1");
    var average = 0.0;
    average = (punits.value + pfrac.value / 100) / this.getField("Days").value;
    this.getField("Average.0").value = average - average % 1;
    this.getField("Average.1").value = util.printx("0099", Math.round((average % 1 * 100))).substr(-2,2);
    �Math.round� appears to be a problem. Also, could you explain the purpose of �0099� . Anyway, why would 154.85 through 154.90 divided by 31 give 4,10. Also, their must be a better way, to find the average daily production. All you have to do is divided the production (whole. fractional) by the days, and display the average daily production as (whole. fractional). Any suggestions??

    There are a many loose ends in your question.
    First, I have never seen before a variable type called 'var'. Is it a java primitive or a class?
    Next, I cannot seem to find any class that has the printx method.
    When it comes to substr(-2,2), I get confused. First, I thought that it was a method of the String class, but I only got as far as substring(beginIndex, endIndex).
    If you really must break the production and average into pieces, try this:
    float average = (punits + pfrac/100) / days;
    int avg_units = (int)average;
    int avg_frac = (int)( (average - avg_units) * 100 );My guess is that util.printx("0099", x) formats x having two optional digits and two mandatory digits, showing 0-99 as 00-99, but allows to show numbers with three and four digits.
    154.85/31 = 4,9951612903225806451612903225806
    154.99/31= 4,9996774193548387096774193548387
    If you round the fraction of theese numbers multiplied by 100 ( = 99.51.. and 99.968...) you get 100, and this will be the output of printx. My guess for "4.10" is that substr(-2,2) returns the two first characters of the string, because the start index should not be zero. (According to java docs, substring throws an exception on a negative index, so what kind of class are you really using ??????)

  • Sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loop

    sir i have given lot of effort but i am not able to solve my problem either with notifiers or with occurence fn,probably i do not know how to use these synchronisation tools.

    sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loopHi Sam,
    I want to pass along a couple of tips that will get you more and better response on this list.
    1) There is an un-written rule that says more "stars" is better than just one star. Giving a one star rating will probably eliminate that responder from individuals that are willing to anser your question.
    2) If someone gives you an answer that meets your needs, reply to that answer and say that it worked.
    3) If someone suggests that you look at an example, DO IT! LV comes with a wonderful set of examples that demonstate almost all of the core functionality of LV. Familiarity with all of the LV examples will get you through about 80% of the Certified LabVIEW Developer exam.
    4) If you have a question first search the examples for something tha
    t may help you. If you can not find an example that is exactly what you want, find one that is close and post a question along the lines of "I want to do something similar to example X, how can I modify it to do Y".
    5) Some of the greatest LabVIEW minds offer there services and advice for free on this exchange. If you treat them good, they can get you through almost every challenge that can be encountered in LV.
    6) If English is not your native language, post your question in the language you favor. There is probably someone around that can help. "We're big, we're bad, we're international!"
    Trying to help,
    Welcome to the forum!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Billing Number Range problem ( accounting document not generated)

    Hi All,
    I have created some billing types and for them I have assigned some internal number ranges. Now when I create a billing document it is getting saved with the proper number range but no accounting document is getting generated.
    Also when I try to release the invoice I am getting an error which says " *Incorrect doc.no.: 10000009. Select document number between 0090000000 and 0099999999* "
    K I N D L Y     suggest  as U R G E N T.
    Regards,
    Danny.

    Dear,
              Billing Number Range problem ( accounting document not generated) is not an error because when you create billing document then accounting document not generated. Accounting done after posting of that billing document with VFX3 or VF02 T.Code by account department.
               And for second issue you had define number range between 0090000000 and 0099999999 for invoice so thats why it happen.
    Regards,
    Sandip Shaktavat

  • Re   Java Stored Procedure Problem

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

  • "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7"

    I'm in the process of publishing the following note (134280.1), titled "How to Resolve ORA-29532 Java 2
    Permission Problems in RDBMS 8.1.6 and 8.1.7".
    It will be accessible from Oracle Support's "Metalink" site.
    "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7".
    Problem Description
    Periodically an application running in the Enterprise Java Engine
    (EJE) formerly known as the "Oracle 8i JVM", "the JSERVER component", or
    the "Aurora JVM" will fail with a "java 2" permissions error having the
    following format :
    Note : Message shown below have been reformatted for easier readability.
    java.sql.SQLException: ORA-29532: Java call terminated by uncaught Java exception:
    usually followed by a detailed error message similar to one of the following
    messages :
    Example # 1
    java.security.AccessControlException: the Permission
    (java.net.SocketPermission hostname resolve)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Example # 2
    java.security.AccessControlException: the Permission
    (java.util.PropertyPermission * read,write)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Example # 3
    java.security.AccessControlException: the Permission
    (java.io.FilePermission \matt1.gif read)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Explanation
    The java 2 permission stated in line # 2 of each of the above "Examples"
    has not been granted to the user specified in line 4 of the above "Examples".
    Solution Description
    The methodology to solve this issue is identical for all java 2 permissions
    cases.
    1) Format a call "dbms_java.grant_permission" procedure as described below.
    2) Logon as SYS or SYSTEM
    3) Issue the TWO commands shown below
    4) Logoff as SYS or SYSTEM
    5) Retry your application
    For Example # 1
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.net.SocketPermission',
    'hostname',
    'resolve');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    For Example # 2
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.util.PropertyPermission',
    'read,write');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    For Example # 3
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.io.FilePermission',
    '\matt1.gif',
    'read');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    References
    For more details on java 2 permissions and security within the EJE, review
    Chapter 5, in the Java Developer's Guide. entitled,
    "Security For Oracle8i Java Applications"
    The RDBMS 8.1.7 version can be found at :
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/index.htm

    Hi, Don,
    I solved the problem of security exception I mentioned at java procedure topic as following:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.SecurityException
    I tried to use your solution as following:
    call dbms_java.grant_permission('SDE', 'java.net.SocketPermission', 'ORCL.COHPA.UCF.EDU','resolve');
    but SQL*plus gave me a error message:
    invalid collumn.
    What's the problem?
    However, I call a grant command as following:
    SQL> grant JAVASYSPRIV to sde;
    and then that exception is gone. What's the difference between dbms_java.grant_permission and grant command?
    Thanks
    Bing
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by don -- oracle support:
    I'm in the process of publishing the following note (134280.1), titled "How to Resolve ORA-29532 Java 2
    Permission Problems in RDBMS 8.1.6 and 8.1.7".
    It will be accessible from Oracle Support's "Metalink" site.
    "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7".
    Problem Description
    <HR></BLOCKQUOTE>
    null

  • Solution Database - Maximum number of Problems and Solutions

    Hi everyone,
    I´m new at CRM and I was wondering if you could help me sharing your knowledge and experience on this.
    I completed the SAF and solution database configuration , I was wondering if there´s a maximum number of problems when creating problems and solutions on IS01? Also Can I have 2 or more solution data bases (with different problems and solutions) assigned for a business role?
    comments are appreciated
    thanks!

    http://help.sap.com/saphelp_crmhana/helpdata/en/a4/9fa471b41f44828da6ea1490f02e2b/frameset.htm
    What about this?
    Best regards,
    Thomas Wagner

  • Please, I am in a very big problem I designed the project by Adobe director And you test the software on the computers on Windows and works with high quality When I tested the project on Apple Macintosh operating system, Li appeared a number of problems

    Please, I am in a very big problem
    I designed the project by Adobe director
    And you test the software on the computers on Windows and works with high quality
    When I tested the project on Apple Macintosh operating system, Li appeared a number of problems and you dissolve a large part of them
    But I have a problem too big
    The project works on some devices and others show me messages mistakes and why chasm different operating system version
    Apple's Macintosh and these messages
    "biosegnatures" can't be opened becouse it 's from undefined developer "
    others
    shokwave player error
    pleas what can i do

    Welcome to the Support Communities.
    m.raslan wrote:
    I tested the project on Apple Macintosh operating system
    Click on the  menu at top left of your screen, choose About This Mac and, in the panel that appears, note the Version no. in the form 10.n.n. Then update your product list so we can see what version of OS X you're running on the Mac — see this tutorial:
    Update your product list
    m.raslan wrote:
    "biosegnatures" can't be opened becouse it 's from undefined developer "
    This Apple doc may help:
    OS X: About Gatekeeper
    m.raslan wrote:
    shokwave player error
    Is Shockwave Player installed?...
    http://www.adobe.com/shockwave/welcome/
    ...If not, get it here:
    http://get.adobe.com/shockwave/

  • Mysteries of Java number 32,194

    Mysteries of Java number 32,194:
    Why the class URL has methods marked "protected", even though it is itself marked "final".
    Drake

    Hey they are thinking about it... for 3 years now http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4880778
    These things take time.

  • Rounding problems

    Dear all,
    We are using the BAPI_ACC_DOCUMENT_POST  to do a reclassification posting F-02 for manager motives.
    We need to calculate the exchange tax. We do Amount in Local Currency / Amount in Forreing Currency.
    The problem is that in the BADI  LV_EXCH_RATE has 13 decimals but GS_CURR-EXCH_RATE moves only 5 decimals so we have rounding problems. We are doing the accounting with GS_CURR-EXCH_RATE that has only 5 decimals.
    Someone know how to move more than 5 decimals on the posting.
    Cheers,
    marta

    Marta,
    why not try to round the variable before you pass it to the badi or round the o/p of the badi before passing it to further processing.
    You can use the formatting options in the write statement CURR/DEC/ROUND to do this in a local variable and then pass the local variable to the badi or pass the o/p of the badi to a local variable, then round it and then use this rounded value.
    Thanks,
    Vikram.M

  • Ipad mini ios7.3. Itunes shows 6.1.3. I've got a number of problems. Is this the Phobos problem I have?

    Ipad mini ios7.3. Itunes shows 6.1.3. I've got a number of problems. Is this the Phobos problem I have?

    Update iTune on your computer (tap image to enlarge)

  • Rounding problem with java.text.DecimalFormat

    I see that the bug reported in relation to this (#4763975) has been closed.
    I'm just wondering when will this bug be fixed or is it even scheduled to be fixed in the future?

    Hi Olli,
    you return sum and not total, but nevertheless returning a double doesn't help as 5.00 will always be 5.0.
    An option would be to return the formatted String.

  • Java number formats?

    Hi.
    I am writing a program which contains a simple division code. The operation divides a word's frequency in a file by the number of words in that file. This is a code strip
    wordCount = wordsInFile(file2); //number of words in file is obtained from a static method
    String w = wordFreq.get(i).toString(); // I get the frequency of the word from an array list
    double wf = Double.parseDouble(w);
    double normalFreq = wf/wordCount;problem is that sometimes this program produces numbers like this : 8.025682182985554E-4
    I have no idea what this means and how to fix it. Is there a specific number format that I should use to avoid this?
    Thanks!
    Message was edited by:
    Yorae

    Hi.
    I am writing a program which contains a simple
    division code. The operation divides a word's
    frequency in a file by the number of words in that
    file. This is a code strip
    wordCount = wordsInFile(file2); //number of
    words in file is obtained from a static method
    String w = wordFreq.get(i).toString(); // I get the
    frequency of the word from an array list
    double wf = Double.parseDouble(w);
    double normalFreq = wf/wordCount;problem is that sometimes this program produces
    numbers like this : 8.025682182985554E-4
    I have no idea what this means and how to fix it. Is
    there a specific number format that I should use to
    avoid this?
    Thanks!
    Message was edited by:
    YoraeTake a look at java.text.DecimalFormat
    double normalFreq = wf/wordCount;
    DecimalFormat df = new DecimalFormat("#.##");
    String output = df.format(normalFreq);
    System.out.println("The formatted double is " + output);This should truncate any digits after the second decimal place (I think it rounds it for you but I havent checked).

  • Java Reflection API problem... Please HELP!

    Hi,
    I'm writing a Client-Server program set where the Server class receives a Java file, along with some parameters, from the Client class/computer.
    The Server class then invokes a certain method from the Java file it received (depending on the parameters received).
    My Server program keeps giving me a ClassNotFoundException, and I'm going crazy.. I've been trying to fix it for a long time now... but with no avail.
    Here's the Server program.. but I doubt you need to read it all. Please just scroll down to "// The line below is what give me problems:".
    package remoterun;
    import java.net.*;
    import java.io.*;
    import java.lang.reflect.*;
    * <p>Copyright: Copyright ms2000 (c) 2005</p>
    public class Server2 {
        public static void main(String args[]) throws Exception {
            int numParameters;
            int port = 6789;
            boolean isThere = false;
            String className, methodName;
            Object[] parameters;
            ServerSocket welcomeSocket = new ServerSocket(port);
            for (; ; ) {
                 * Create a new socket, called connectionSocket, when some client knocks
                 * on welcomeSocket. This socket has the same port number. TCP then
                 * establishes a direct virtual pipe between the client socket and
                 * connectionSocket at the server so the client and server can send bytes
                 * to each other over it.
                Socket connectionSocket = welcomeSocket.accept();
                // Get number of parameters
                DataInputStream in = new DataInputStream(new BufferedInputStream(
                        connectionSocket.getInputStream()));
                numParameters = in.readInt();
    // Get the parameters for the method to be invoked.
                parameters = new Object[numParameters];
                ObjectInputStream objStream = new ObjectInputStream(
                        connectionSocket.getInputStream());
                for (int i = 0; i < numParameters; i++) {
                    parameters[i] = objStream.readObject();
                // read the class
                File program = (File) objStream.readObject();
                System.err.println(program); // It prints the program name correctly, e.g. Class2.java
    // Receiving some String parameters...
                            BufferedReader inFromClient = new BufferedReader(new
                        InputStreamReader(connectionSocket.getInputStream()));
                className = inFromClient.readLine();
                methodName = inFromClient.readLine();
                // The line below is what give me problems:
                Class classDefinition = Class.forName("remoterun." + className + ".java");
                Object object = classDefinition.newInstance();
                Method[] theMethods = classDefinition.getMethods();
                for (int i = 0; (i < theMethods.length) && (!isThere); i++) {
                    if (theMethods.getName().equals(methodName)) {
    isThere = true;
    theMethods[i].invoke(object, parameters);
    The Client code just sends the stuff to the Server, and it works fine. The code is below if it may help:
    package remoterun;
    import java.net.*;
    import java.io.*;
    public class Client2 {
        public static void main(String[] args) throws Exception {
            int result;
            int port = 6789;
            int num1 = 5;
            int num2 = 6;
            int numParameters = 3;
            String hostIP = "127.0.0.1";
            String className = "Class2";
            String methodName = "add";
            Object[] parameters;
            Socket clientSocket = new Socket(InetAddress.getByName(hostIP),
                                             port);
            // Send numParameters, className, methodName
            DataOutputStream out = new DataOutputStream(new BufferedOutputStream(
                    clientSocket.getOutputStream()));
            out.writeInt(numParameters);
            out.flush();
            Integer num3 = new Integer(num1);
            Integer num4 = new Integer(num2);
            parameters = new Object[] {num3, num4, InetAddress.getLocalHost()};
            File program = new File((className + ".java"));
            ObjectOutputStream output = new ObjectOutputStream(clientSocket.
                    getOutputStream());
            for (int i = 0; i < numParameters; i++) {
                output.writeObject(parameters);
    output.writeObject(program);
    output.flush();
    DataOutputStream outToServer = new DataOutputStream(clientSocket.
    getOutputStream());
    outToServer.writeBytes(className + '\n');
    outToServer.writeBytes(methodName + '\n');
    outToServer.flush();
    clientSocket.close();
    The error I get from the Server class is:
    java.lang.ClassNotFoundException: remoterun.Class2.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at remoterun.Server2.main(Server2.java:94)
    Exception in thread "main"
    (I also get a dialog box saying sthg like, "A fatal exception occured.. will exit now".)
    It's really odd, becuase there were rare times when it works although I don't change the program...
    I tried changing the problem line to stuff like:
                Class classDefinition = Class.forName(className + ".java");or
       Class classDefinition = Class.forName(className);but with no use. Same error. Can someone please pinpoint the problem?
    I'm sure the program does get to the Server, because it can print out the file name.
    PS: Sometimes it works when I use the same PC as the client/server, sometimes it doesn't.... Help :-(
    I'd appreciate some assistance in this.
    Thank you.

    What's this dot-java stuff? Are you sending a source file? If so, that isn't going to work. You need to compile the file and send the dot-class file.
    I'll try that. However, can I make the Client program complie the .java file? For example. something like Class2.compile()? Is this feature available, or do I have to open Class2.java and compile it from there?
    And in the server you need to either store that somewhere in the server's classpath....
    Isn't it automatically stored there? If not, how do I make it stored in the same file as the Server source file (I assume that's what you mean by classpath)?
    Thanks for your help... !!!

Maybe you are looking for

  • Purchase Requisition not calculating tax

    Hi I have a problem with the requisitions,when we raise a requisition it is suppose to calculate tax(VAT) but for some requisitions it doen't, any idea

  • I dropped my laptop and now the screen is in yellow tint

    Hi, I recently dropped my laptop and turned it on to find that the screen is in yellow tint. Will Toshiba be able to replace my screen?

  • So what's really new in iTunes Match 10.52?

    10.52 was released today, and I've installed it.  I was hoping it would deal better with a bunch of albums I've imported where it can match some of the songs, but not all of them.  I actually logged it, and will put it in another post.   But my initi

  • After "cleaning up" my fonts, all text in certain websites is bold. Please help.

    About a week ago, I deleted every font in font book that had a yellow circle (this is a problematic font) warning next to it, thinking that it would help stabilize Word. Now all the text on certain websites, e.g. https://www.lexisnexis.com/start/sign

  • Converting date in french format

    Hi All, Hi All, Please let me know if you have any idea I am converting the date to French /infact multi lang select to_char(sysdate,'Fmddth Month, yyyy','NLS_DATE_LANGUAGE =FRENCH') from dual so this is giving me "8th Septembre, 2011" but what i wan