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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Conversion of a floating point type field

    Hi,
    I'm fetching field ATFLV from table AUSP for a particular value of ATINN.ATFLV is a floating point type field.
    Can anyone please guide me as to how to convert this field(ATFLV) from floating point no. to a simple no.?
    Helpful answers will be rewarded.
    Regards,
    Sipra

    hi,
    Do like this,
    float f = 234.33;
    int i = (int) f; // i has value 234.
    reward points if helpful..

  • 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

  • Char is a floating point type!?!

    The sample test on http://www.scja.de/scja-mock-exam-section1.html states that char is a floating point type..... is this correct?

    No it isn't ! Sorry for the mistake - it's corrected right now.
    regards,
    Ralf Peter

  • 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).

  • In sales order for the condition type MWST, **Tax code** is displaying wron

    Hi
    In sales order for the condition type MWST, *Tax code* is displaying wrongly at header level i.e. FF instead of AO (under account determination tab)
    AO tax is 0% but for FF it is 19%
    I have checked with the Access sequence it is picking access 08 correctly according to this it should show AO in tax code field for MWST but it is not so..
    There is a manual change for tax classification for material master in va02 initially it was blank now it is changed to ' 0 ' is any way influencing....?
    Even if I consider material tax classification and customer tax code  should not be FF because  tax code  FF is not maintained for the combination of access sequences for condition type MWST
    Please help me.
    Rajendra Prasad

    Dear Rajendra,
    There is a manual change for tax classification for material master in va02 initially it was blank now it is changed to ' 0 ' is any way influencing....?
    Definitely material Tax classification will influence to determine the Tax code.
    -->So Make sure that customer and material master having proper tax classification indicator.
    -->Have you Update the price after changing the tax classification in the sales order.by going to item dat -->condition tab then click on Update push button bottom of the conditions screen.
    -->Once again the check the condition record maintanence also for your MWST access sequence.
    I hope this will help you,
    Regards,
    Murali.

  • Floating Point type in selection screen

    Hi,
    I need to use a field ausp-atflv in selection screen. Field atflv of type Floating point. But in selection-screen, Floating point type variables are not allowed.
    Any suggestions please.
    Thanks
    Aravind.R

    Yes Arvind,
    Replace the type with a TYPE P with DECIMALS addtion variable.
    Regards
    Abhii

  • 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;
    }

  • Stop Automatic creation and confirmation of Transafer Order for a doc type

    Hello All,
    There is a requirement that I need to stop Automatic creation and confirmation of Transafer Order for a particular document type.
    The issue is that sometimes the cycle goes upto creation of Invoice automatically but sometimes this does not happen. More over the user wants that the transafer order needs to be confirmed manually.
    Can u please provide the .steps involved for thie case.
    Thanks
    Chandrashekhar

    Dear Steve,
    Thanks a lot for giving reply with what I need to do, but I am unable to see result.
    I have down configuration like below even though system not processing Auto TO creation. Can you explain me if I have down any mistake below.
    Click on ‘Assign’ button,
    Press on ‘New entries’
    WhN = ‘900’
    Reference Movement Type = ‘101’
    Movement indicator = ‘B’
    Movement type for Whse Mgmt = ‘101’
    TR create Transfer Requirement = ‘X’
    Immed.TO Creation
    Mail confirmation for background processing = ‘01’.
    GR date = ‘2’

  • How to see planned orders for P3 mrp type products in APO?

    Dear experts,
    I have materials with P3 MRP type (not planned in APO but in R/3 using MRP)
    I have active integration models with P3 and X0 mrp type products for planned orders
    however I can not see in APO product view the planned orders for P3 materials,
    is this normal or should I see those planned orders in APO?
    Thanks for your answer,
    best regards
    Elynn

    Hi,
    The following prerequisites must be met so that planned orders can be transferred from SAP R/3 to SAP APO
    and vice versa:
    1.The material masters must be transferred to SAP APO.
    2. PPMs must exist for planning in SAP APO.
    3. The relevant integration models must be active.
    4. An active integration model for planned orders must exist in SAP R/3.
    5.An active integration model must also exist for materials, so that the components of the planned order are transferred.
    6.The relevant distribution definitions must be maintained in SAP APO, so that planning results can be
       transferred from SAP APO to SAP R/3.
    Thanks,
    nandha

  • Anchor order for floats not the same as positioned frames?

    Hi,
    FM 8.04, Win XP.
    When creating two anchored frames (set to "Float" and "Top of column") in the body text, where Anchor A is a couple of lines above above Anchor B in the text, Frame B is actually displayed on the same page and Frame A on the next page.
    Is this behavior typical for floats in FM? Sure, I had expected that the frames were floated, but that the anchor order was respected.
    Thanks,
    Mats

    Mats,
    IIRC, the float option specifies that the frame can move to the next
    column that can physically hold it. So this functionality is also
    dependent upon the frame and column size, not just the order of the
    frames. I also believe that the top/bottom settings have priority over
    the float setting (as by it's nature, the user has stated that they
    don't care where this frame ends up).
    In your example, with the second frame being set to top of column,
    this takes away room from the second frame set to float, so it
    migrates to the next available column that it can fit in.

  • 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

  • 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)

  • Sales order for pipeline material type..

    Hi All,
    How can we raise the sales order for pipeline material..
    Is schedule lines will be there for the sales order raised for pipeline material???
    Rgds,
    Pavan

    Hi
    Seems you working on  IS Utilities, please corerct if Wrong and if I am wrong to guess you are working on IS Utilities then the next story dosn't make any sence.
    PIPEline material type is used for Materials such as oil, power, or water that flow into the production process directly from a pipeline, line, or other type of conduit. Since pipeline materials are always available, they are not planned.
    To answer specifically what you asked would be as follows:
    1. The fact that material type is PIPE from an SD standpoint is irrelevant
    2. lets consider your PIPEline material is power, your UOM should be Kilowatt hours and establish price for it.
    3. "deliver" the material and bill it.
    However, taking the whole business context of sale of electricity into account why you want to sell PIPEline material without using IS Utilities. Typically electrical utiltity requirements have some unique challenges not easily met by SD:
    1. Amount to be billed to the customer is from meter readings.
    2. The bill to the customer ( at least in North America) is not so much of an invoice as opposed to statement of accounts that includes meter readings, consumption history etc.
    I will suggest to look into IS Utilties first before getting into SD.

  • Getting precision length  for float data type

    Hi All,
    We trying to find the precision length of a float (126) data type. Are there any built in functions in oracle for finding the same? E.g: the function should return 5 for the value 1.23456 .
    Also, are there any table level operation to reduce the decimal precision of a float 126 field?
    Regards,
    Raj.

    Not sure if this is what you're looking for:
    select data_precision from all_tab_columns
    where owner = '<your schema name>'
    and table_name = '<your table name>'
    and column_name = '<name of column in table>';
    or are you looking for a particular find_precision_in_number() function...
    i can't think of one off the top of my head, but you can always do:
    length(substr(<colname>, instr(<colname>, '.')+1))

Maybe you are looking for