Re: Blow me away, (long) does not truncate.
From: Roedy Green (look-on_at_mindprod.com.invalid)
Date: 06/01/04
- Next message: Andrew Thompson: "Re: FileDialog Filefilter"
- Previous message: Andrew Thompson: "Re: Problem with storing properties"
- In reply to: Yu SONG: "Re: Blow me away, (long) does not truncate."
- Next in thread: Ryan Stewart: "Re: Blow me away, (long) does not truncate."
- Reply: Ryan Stewart: "Re: Blow me away, (long) does not truncate."
- Reply: Nigel Wade: "Re: Blow me away, (long) does not truncate."
- Reply: Thomas Schodt: "Re: Blow me away, (long) does not truncate."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 01 Jun 2004 16:38:56 GMT
On Tue, 01 Jun 2004 09:41:47 +0100, Yu SONG <tips@mi6.gov.uk> wrote or
quoted :
>The rules are here:
>http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#25363
The rules are ambiguous.
They say they "round toward 0" which could mean ether truncation
toward 0 or rounding toward 0.
In their example they say:
System.out.print("cast to int rounds toward 0: ");
d = 12345.6;
System.out.println((int)d + " " + (int)(-d));
produces the output:
cast to int rounds toward 0: 12345 -12345
I ran the test and it indeed truncates.
Which suggests they mean truncation.
Yet the example I ran shows it sometime does rounding.
The mystery is explained at http://mindprod.com/jgloss/truncation.html
-- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
- Next message: Andrew Thompson: "Re: FileDialog Filefilter"
- Previous message: Andrew Thompson: "Re: Problem with storing properties"
- In reply to: Yu SONG: "Re: Blow me away, (long) does not truncate."
- Next in thread: Ryan Stewart: "Re: Blow me away, (long) does not truncate."
- Reply: Ryan Stewart: "Re: Blow me away, (long) does not truncate."
- Reply: Nigel Wade: "Re: Blow me away, (long) does not truncate."
- Reply: Thomas Schodt: "Re: Blow me away, (long) does not truncate."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|