UDP and float/double values - Java-Games

This is a discussion on UDP and float/double values - Java-Games ; Hi, I've been working lately on a multiplayer module for a simulator, which would require me to transmit 12 double values (96 bytes) as often as 10 times per second. Those values are needed in their full precision and constantly ...

+ Reply to Thread
Results 1 to 3 of 3

UDP and float/double values

  1. Default UDP and float/double values

    Hi,

    I've been working lately on a multiplayer module for a simulator, which
    would require me to transmit 12 double values (96 bytes) as often as 10
    times per second. Those values are needed in their full precision and
    constantly change, so I can't dismiss them.

    I know that passing directly float and double values can result in
    unpredictable results, as there is no such thing as htons() for those
    types. I would prefer not to transmit those values in a string format,
    since it seems like a complete waste of bandwidth and precision.

    Any suggestions?

  2. Default Re: UDP and float/double values


    Remy Villeneuve wrote:
    > I know that passing directly float and double values can result in
    > unpredictable results, as there is no such thing as htons() for those
    > types. I would prefer not to transmit those values in a string

    format,
    > since it seems like a complete waste of bandwidth and precision.
    >
    > Any suggestions?


    Represent every float/double as 2x integers. One for the integer part
    and one for the fractional part...?

    T


  3. Default Re: UDP and float/double values

    T wrote:

    > Remy Villeneuve wrote:
    >
    >>I know that passing directly float and double values can result in
    >>unpredictable results, as there is no such thing as htons() for those
    >>types.


    Sure there are. Look up "htonf" and "htond". FlightGear, for
    one, uses those.

    John Nagle

+ Reply to Thread

Similar Threads

  1. double and float
    By Application Development in forum labview
    Replies: 0
    Last Post: 12-06-2007, 10:10 AM
  2. Converting double (or float) to int
    By Application Development in forum c++
    Replies: 1
    Last Post: 06-08-2007, 02:51 PM
  3. why .Net Matrix use float, but not double
    By Application Development in forum DOTNET
    Replies: 2
    Last Post: 04-28-2007, 05:10 PM
  4. float v double, esp in JOGL
    By Application Development in forum Graphics
    Replies: 19
    Last Post: 10-04-2006, 02:44 PM
  5. Limits of float and double ?
    By Application Development in forum Java
    Replies: 3
    Last Post: 11-07-2003, 07:04 PM