Performance for floating point/packed decimal arithmec expressions

Hi,
i need to loop over a big internal table doing some intense mathemtical operations with floating numbers.
The compiler does not allow this:
  a = 60.0 * b.
Instead i have to write
  a = '60.0' * b.
Now i'm afraid that the string 60.0 is converted to float in every loopstep. This conversion is just wasting of time. Even if i use
  a = 60 * b.
there will be a lots of conversions from interger to float.
My first question is if i'm right that '60.0' is converted over and ovber again to float and the second one is how can i avoid that?
My first idea is to define constants with the right type and then use these constants inside the loop avoidung the conversions. Any other ideas, hints, corrections to my assumptions?

i went to SE30 Tips&Tricks and compared
constants:
  co_60 type float value '60.0'.
data:
  a type float,
  b type float.
a = 3.
do 10000 times.
  a = b * co_60.
enddo.
with
constants:
  co_60 type float value '60.0'.
data:
  a type float,
  b type float.
a = 3.
do 10000 times.
  a = b * '60.0'.
enddo.
there is a significant difference in the runtime. I guess the compiler does not really optimize here.
By the way: i cant understand OSS Note 1465138.... if i have S_DEVELOP i can execute code with se38, its irrelevant id se30 is open for editing or not...i made a copy of rshowtim in D system

Similar Messages

  • Separator for floating point numbers

    Hello,
    I work with oracle 9 and have a problem with the entry of floating point numbers.
    The separator for floating point numbers in my data is a point (5.60).
    The pre-setting of oracle is a comma (5,60).
    By inserting I get the error message:
    01722. 00000 - "invalid number"
    How can i change this setting
    Thanks for Help
    F.

    Hi,
    I'm not sure if I understood your problem, however the NLS_NUMERIC_CHARACTERS variable specifies the characters to use as the group separator and decimal character.
    SQL> create table t1 (val number);
    Table created.
    SQL> select * from nls_session_parameters;
    PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  BRAZIL
    NLS_CURRENCY                   R$
    NLS_ISO_CURRENCY               BRAZIL
    NLS_NUMERIC_CHARACTERS ,.
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD/MM/YYYY
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT           DD/MM/RR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT             HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD/MM/RR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY              Cr$
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    17 rows selected.
    SQL> insert into t1 values (1.50);
    1 row created.
    SQL> select * from t1;
           VAL
           1,5
    SQL> alter session set nls_numeric_characters='.,';
    Session altered.
    SQL> select * from t1;
           VAL
           1.5Cheers
    Legatti

  • F suffix for floating point.

    Okay, I'm a proficient c++ programmer and have been learning Java for only a few weeks now.
    I have a question about the f suffix for floating point varibles such as float f = 3.14f;
    The f suffix casts this as float right? which is the same as float f = (float) 3.14; Correct?
    Why do we have to add the f suffix in the first place? Doesn't the compiler know that we want a float and not a double? (single-precision 32-bit instead of double precision 64 bit) I really do not understand the concept here or why they need the f suffix.
    Can someone explain?

    ThePHPGuy wrote:
    The f suffix denotes that the literal is of a floating-point type.Yes. The d suffix does the same.
    Java has two different types of floating-point numbers.Right.
    The type double is the default type.Right.
    The float type can have a double and a float literal. Is this true or false?No. At least not in any way I understand it.
    I think you're confusing two things:
    "floating point number" is any number in the IEEE floating point format.
    "float" is a datatype holding a 32bit floating point number.
    "double" is a datatype holding a 64bit floating point number.
    floating point number literals can be either double literals (without suffix or if the "d" suffix is used) or float literals (when the "f" suffix is used).

  • Regular Expression for floating point numeric field

    Hi,
    the requirements for the field are as follows:
    - floating point numeric field 7 digits in length
    - the field must contain a decimal (dot) and either one, two or three digits to the right of the decimal
    - (leading zeroes are required if needed to fill up the 7 characters)
    My example shown below does not check for the length of 7 characters:
    public static void main(String[] args) {
        String str = "04100.0";
        System.out.println(str);
        Pattern f_1To7 = Pattern.compile("^([0-9]*\\.[0-9]{1,3})$");
        Matcher matcher = f_1To7.matcher(str);
        if (matcher.find()) {
            // yes, we've found something
            System.out.println("We matched the pattern!");
        } else {
            System.out.println("Better luck next time!");
    }When changing the pattern to
    ^([0-9]*\\.[0-9]{1,3}){7}$the whole expression will be repeated 7 times - but I would like to have to whole String to be 7 characters long.
    Here are some examples for the field:
    050.500 or 04100.0Thanks a lot and best regards,
    - Stephan

    Jackler wrote:
    Perhaps I did not express clearly enough. My problem is not a java issue - what I need is a regular expression (pattern) suiting my requirements:
    -floating point numeric field 7 digits in length
    -contains a decimal and either one, two or three digits to the right of the decimal
    ...Assuming that you are going to use Java*, you could use a lookahead at the start of your regex:
    "^(?=\\d{4,6}\\.\\d{1,3}$).{8}$"Meaning:
    ^             # match the start of the string
    (?=           #
      \d{4,6}     #   ensure that there are between 4 and 6 digits...
      \.          #   followed by a DOT...
      \d{1,3}     #   followed by 1 to 3 digits
    .{8}$         # match exactly 8 characters directly followed by the end of the string* or some other language that has look-ahead support (most PCRE implementations have them)

  • Designing for floating point error

    Hello,
    I am stuck with floating point errors and I'm not sure what to do. Specifically, to determine if a point is inside of a triangle, or if it is on the exact edge of the triangle. I use three cross products with the edge as one vector and the other vector is from the edge start to the query point.
    The theory says that if the cross product is 0 then the point is directly on the line. If the cross product is <0, then the point is inside the triangle. If >0, then the point is outside the triangle.
    To account for the floating point error I was running into, I changed it from =0 to abs(cross_product)<1e-6.
    The trouble is, I run into cases where the algorithm is wrong and fails because there is a point which is classified as being on the edge of the triangle which isn't.
    I'm not really sure how to handle this.
    Thanks,
    Eric

    So, I changed epsilon from 1e-6 to 1e-10 and it seems to work better (I am using doubles btw). However, that doesn't really solve the problem, it just buries it deeper. I'm interested in how actual commercial applications (such as video games or robots) deal with this issue. Obviously you don't see them giving you an error every time a floating point error messes something up. I think the issue here is that I am using data gathered from physical sensors, meaning the inputs can be arbitrarily close to each other. I am worried though that if I round the inputs, that I will get different data points with the exact same x and y value, and I'm not sure how the geometry algorithms will handle that. Also, I am creating a global navigation mesh of triangles with this data. Floating point errors that are not accounted for correctly lead to triangles inside one another (as opposed to adjacent to each other), which damages the integrity of the entire mesh, as its hard to get your program to fix its own mistake.
    FYI:
    I am running java 1.6.0_20 in Eclipse Helios with Ubuntu 10.04x64
    Here is some code that didn't work using 1e-6 for delta. The test point new Point(-294.18294451166435,-25.496614108304477), is outside the triangle, but because of the delta choice it is seen as on the edge:
    class Point
         double x,y;
    class Edge
         Point start, end;
    class Triangle
         Edge[] edges;
         public Point[] getOrderedPoints() throws Exception{
              Point[] points = new Point[3];
              points[0]=edges[0].getStart();
              points[1]=edges[0].getEnd();
              if (edges[1].getStart().equals(points[0]) || edges[1].getStart().equals(points[1]))
                   points[2]=edges[1].getEnd();
              else if (edges[1].getEnd().equals(points[0]) || edges[1].getEnd().equals(points[1]))
                   points[2]=edges[1].getStart();
              else
                   throw new Exception("MalformedTriangleException\n"+this.print());
              orderNodes(points);
              return points;
            /** Orders node1 node2 and node3 in clockwise order, more specifically
          * node1 is swapped with node2 if doing so will order the nodes clockwise
          * with respect to the other nodes.
          * Does not modify node1, node2, or node3; Modifies only the nodes reference
          * Note: "order" of nodes 1, 2, and 3 is clockwise when the path from point
          * 1 to 2 to 3 back to 1 travels clockwise on the circumcircle of points 1,
          * 2, and 3.
         private void orderNodes(Point[] points){
              //the K component (z axis) of the cross product a x b
              double xProductK = crossProduct(points[0],points[0], points[1], points[2]);
              /*        (3)
               *          +
               *        ^
               *      B
               * (1)+             + (2)
               *       ------A-->
               * Graphical representation of vector A and B. 1, 2, and 3 are not in
               * clockwise order, and the x product of A and B is positive.
              if(xProductK > 0)
                   //the cross product is positive so B is oriented as such with
                   //respect to A and 1, 2, 3 are not clockwise in order.
                   //swapping any 2 points in a triangle changes its "clockwise order"
                   Point temp = points[0];
                   points[0] = points[1];
                   points[1] = temp;
    class TriangleTest
         private double delta = 1e-6;
         public static void main(String[] args)  {
                    Point a = new Point(-294.183483785282, -25.498196740397056);
              Point b = new Point(-294.18345625812026, -25.49859505161433);
              Point c = new Point(-303.88217906116796, -63.04183512930035);
              Edge aa = new Edge (a, b);
              Edge bb = new Edge (c, a);
              Edge cc = new Edge (b, c);
              Triangle aaa = new Triangle(aa, bb, cc);
              Point point = new Point(-294.18294451166435,-25.496614108304477);
              System.out.println(aaa.enclosesPointDetailed(point));
          * Check if a point is inside this triangle
          * @param point The test point
          * @return     1 if the point is inside the triangle, 0 if the point is on a triangle, -1 if the point is not is the triangle
          * @throws MalformedTriangleException
         public int enclosesPointDetailed(LocalPose point, boolean verbose) throws Exception
              Point[] points = getOrderedPoints();          
              int cp1 = crossProduct(points[0], points[0], points[1], point);
              int cp2 = crossProduct(points[1], points[1], points[2], point);
              int cp3 = crossProduct(points[2], points[2], points[0], point);
              if (cp1 < 0 && cp2 <0  && cp3 <0)
                   return 1;
              else if (cp1 <=0 && cp2 <=0  && cp3 <=0)
                   return 0;
              else
                   return -1;
             public static int crossProduct(Point start1, Point start2, Point end1, POint end2){
              double crossProduct = (end1.getX()-start1.getX())*(end2.getY()-start2.getY())-(end1.getY()-start1.getY())*(end2.getX()-start2.getX());
              if (crossProduct>floatingPointDelta){
                   return 1;
              else if (Math.abs(crossProduct)<floatingPointDelta){
                   return 0;
              else{
                   return -1;
    }

  • Byte Order for Floating Point Types

    I need to send an array of floating point values from an x86 C++ application to a Java application. I am using a socket to transfer the data. What, if anything, do I have to do about preserving the correct byte order?

    Probably nothing.
    If you do end up having a problem, look at the java.nio package. Specfically, java.nio.ByteOrder, and java.nio.Double/FloatBuffer.
    To be completely safe, I think I'd probably send an enum in some kind of header that indicates what byte order your C++ is sending and use the *Buffer classes to automatically handle the conversion.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Is there any java Charset for converting EBCDIC packed decimal to ASCII?

    Pls reply if you know the solution.

    This is not a function of a Charset, because of the packing. There are plenty of EBCDIC<->ASCII libraries out there.

  • Convert float to packed decimal

    Hi Gurus,
    can you plz solve following.
    I have afields as below,.
    it_plmk-toleranzob
    I have to convert value of above this field up to  it_plmk-stellen dacimal places.
    where value of it_plmk-stellen is 4.
    for exapmles.
    it_plmk-stellen = 4
    it_plmk-toleranzob = 1.1799999999999999E+00
    I want it_plmk-toleranzob  to be 1.1800. how can i do.
    Regards
    Rajesh

    Hi,
    You can try with the FM 'MURC_ROUND_FLOAT_TO_PACKED'.
    Hope it works.
    Thanks,
    Sandeep.

  • Floating point Number & Packed Number

    Hai can anyone tell me what is the difference in using floating point & packed Number .
    when it will b used ?

    <b>Packed numbers</b> - type P
    Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
    You can use type P data for such values as distances, weights, amounts of money, and so on.
    <b>Floating point numbers</b> - type F
    The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
    You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.
    Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
    reward if useful

  • Floating-point addition unit

    Hello All,
    I am very new to NI and I am looking for an example of floating-point addition unit. Basically, I am looking for some example to perform addition of two floating point number (single or double precision). -- just how to create floating-point addition unit using logical gates model (i.e. AND, OR, XOR, etc)
    Thank you!
    Leo
    Message Edited by smuStudent on 12-05-2005 11:51 PM

    Most (if not all) of us, when we want to do floating point math just put the Add function onto the block diagram. I would suggest you google for floating point gates or something similar. You can create subVIs that make up the basic functions such as a full adder and then link them together as needed.
    Attachments:
    Full Adder.JPG ‏9 KB

  • Niagara II Floating Point Operations

    Niagara II has much improved floating point performance over Niagara I, however I'm wondering if performance of floating point intensive threads could be improved, by amalgamating the floating point processing from each core to a dedicated unit that can execute in parallel, the instructions from all threads, such that if a single core, experiences a floating point intensive load, the floating point load aggregate over the entire processor is better optimized?

    pfirmst wrote:
    Niagara II has much improved floating point performance over Niagara I, however I'm wondering if performance of floating point intensive threads could be improved, by amalgamating the floating point processing from each core to a dedicated unit that can execute in parallel, the instructions from all threads, such that if a single core, experiences a floating point intensive load, the floating point load aggregate over the entire processor is better optimized?I'm not a hardware designer, but I think there are two problems with this approach.
    a. There would probably need to be extra interconnect and arbitration to get from the issue pipeline to the shared floating-point units and back again with the result. This would tend to add latency to the floating-point instruction execution and would probably be bad for performance. For example, the floating-point latency on T1 is about 26 cycles and on T2 it's about 6 cycles.
    b. In order to get more floating-point performance from a single thread, the issue logic would also need to be changed to be able to issue more floating-point instructions in a single cycle (i.e. superscalar issue). This would be good for single thread performance, but would require more complexity and space, and may impact the number of cores/threads that can fit on a single chip. The correlary is that since each T2 core can only issue two floating-point instructions per cycle (one from each of two threads), each core could make use of at most two floating-point units.
    On CMT chips, sharing is good, because it leads to higher efficiency and utilization,
    but too much sharing can also hurt performance. There needs to be balance in the design.
    Peter.

  • Floating Point Representations on SPARC (64-bit architecture)

    Hi Reader,
    I got hold of "Numerical Computation Guide -2005" by Sun while looking for Floating Point representations on 64 bit Architectures. It gives me nice illustrations of Single and Double formats and the solution for endianness with
    two 32-bit words. But it doesn't tell me how it is for 64-bit SPARC or 64-bit x86.
    I might be wrong here, but having all integers and pointers of 64-bit length, do we still need to break the floating point numbers and store them in lower / higher order addresses ??
    or is it as simple as having a Double Format consistent in the bit-pattern across all the architectures (Intel, SPARC, IBMpowerPC, AMD) with 1 + 11 + 52 bit pattern.
    I have tried hard to get hold of a documentation that explains a 64-bit architecture representation of a Floating Point Number. Any suggestion should be very helpful.
    Thanks for reading. Hope you have something useful to write back.
    Regards,
    Regmee

    The representation of floating-point numbers is specified by IEEE standard 754. This standard contains the specifications for single-precision (32-bit), and double-precision (64-bit) floating-point numbers (There is also a quad-precision (128-bit) format as well). OpenSPARC T1 supports both single and double precision numbers, and can support quad-precision numbers through emulation (not in hardware). The fact that this is a 64-bit machine does not affect how the numbers are stored in memory.
    The only thing that affects how the numbers are stored in memory is endianness. SPARC architecture is big-endian, while x86 is little-endian. But a double-precision floating-point numer in a SPARC register looks the same as a double-precision floating-point number in an x86 register.
    formalGuy

  • Pack  and Floating Point Data Type in ABAP

    Dear All,
    I am new to ABAP. Started with data types. Came across pack and floating point.
    Please let me know what PACK  and Floating Point stands for with few examples and the main difference between them.
    Regards
    Arun V

    Hi,
    You'd better ask this question in ABAP forum http://forums.sdn.sap.com/forum.jspa?forumID=50 .
    Best Regards,
    Ada

  • 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

  • Floating point performance

    Hi, I'm trying to investigate floating point performance on an iPhone device vs. using fixed point math. Does the iPhone have a FPU? Are there any papers in the developer iPhone reference library that talk about this subject ( I did a search but nothing seemed to come up ). Anybody have any thoughts / comments about this?
    Any help would be great! Thanks!

    Unfortunately the ARM documentation is lousy and it is hard to estimate what would happen vis-a-vis the thumb compile switch. I suspect apple tested it thoroughly and determined a majority of apps would benefit with it ON. But hey go ahead and try it and please let us know.
    the FPU in the arm is reasonably powerful, but somehow I doubt that the GCC compiler will generate any code worth a snot in terms of taking advantage of it, likely you will have to dip into assembler to use it to advantage.
    I am a long time Microsoft Intel assembler fan - gotta love one of the best macro assemblers even written by anybody. You can get a 4 times increase in your app if you hand code it, but most of us are limited by the operating system and memory vs. pure CPU. I suspect gamers will find the iPhone frustrating as we are all doing Objective-C which is a super high overhead language, although not as bad as Java, which is a language best suited for snails.

Maybe you are looking for