Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 4th, 2008, 06:04 PM
Registered User
 
Join Date: Jan 2008
Location: , Florida, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Double values

I'm having a hard time understanding the doubles, floats etc.

Are the values of (double) 1/2 and (double) (1/2) the same or are they different?

Reply With Quote
  #2 (permalink)  
Old February 5th, 2008, 12:15 AM
jomet
Guest
 
Posts: n/a
Default

Hi,

different
(double) 1/2 => double of 1 divided by 2
(double) (1/2) => double of 1/2

I this case it will not generate much diff
but if 1/3(ex only .33333333333) rounding takes for precision then it matters.

# float: The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in section 4.2.3 of the Java Language Specification. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead. Numbers and Strings covers BigDecimal and other useful classes provided by the Java platform.

# double: The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in section 4.2.3 of the Java Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.

Cheers,


jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
double in binär walid C# 1 January 24th, 2007 03:23 PM
double bookings urbanaccess Access 1 January 18th, 2007 08:41 AM
double quotes MyronCope Classic ASP Basics 2 November 21st, 2006 09:31 AM
Double Quotes langer123 Classic ASP Basics 2 March 16th, 2005 06:22 PM
double to string? chris97b Visual C++ 4 September 23rd, 2003 02:34 PM



All times are GMT -4. The time now is 09:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.