Results 1 to 3 of 3
  1. #1
    gbonecapone is offline Member
    Join Date
    May 2013
    Rep Power

    Default Are there real numbers in Java?

    I am trying to rewrite this truebasic program over to java and most of it is working but sometimes the outcome(degrees) is one more than the original's outcome.
    im assuming its a rounding error since it doesnt happen everytime. the only thing different is that im not using real numbers like in this line of the old code. is there a way to do that in Java?

    IF temq >= 360! THEN temt = temt + 1!: temq = temq - 360
    REM "! for real (as opposed to integer)

    and also there was this line:

    temp = t - INT(t): temq = 360 * temp + .5

    to replace INT(t) ive been using Math.rint(t) and Math.round(t). neither seemed to be different in this case from what i noticed.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Are there real numbers in Java?

    Try using float or double (preferred). However, even the latter has its limitations associated with precision.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Are there real numbers in Java?

    To be exact: Java uses the IEEE/459 number system; it is a number system that can represent a very funny subset of the set Q (rational numbers) which is a subset of the set R (real numbers); it's the best you can do on any digital computer with a finit amount of memory for a single number.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. help with Java real-time midi
    By mike1127 in forum New To Java
    Replies: 6
    Last Post: 03-12-2013, 01:31 AM
  2. JAVA real-time RTSJ or C++
    By yoshi in forum Forum Lobby
    Replies: 1
    Last Post: 05-09-2012, 07:38 PM
  3. How real-time is java?
    By StateMachine in forum New To Java
    Replies: 12
    Last Post: 12-27-2011, 04:41 PM
  4. Need assistance with real numbers
    By studentone in forum New To Java
    Replies: 7
    Last Post: 11-13-2011, 06:17 PM
  5. real world java
    By Zosden in forum Forum Lobby
    Replies: 6
    Last Post: 06-25-2008, 05:39 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts