Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Urgent  RSS feed

 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I wish to calculate and dispaly the sum of figures. I tried t with float, long and double. Still i'm getting following kind of output.
5246548
+5329785
---------
TOTAL: 1.0576333E7
Can anyone help me in this???
Thanx
Grishma
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got the right answer. It's just in scientific notation. I suggest that you assign the answer to a long and print the long.
long answer = 5246548 + 5329785 ;
System.out.println( answer );
I think that this should give you what you're looking for.
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've converted it into long but bcoz of that i'm getting rounded off figures. I'm not able to get values after decimal pt.
[ January 29, 2004: Message edited by: Grishma Dube ]
 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Grishma Dube:
I've converted it into long but bcoz of that i'm getting rounded off figures. I'm not able to get values after decimal pt.
[ January 29, 2004: Message edited by: Grishma Dube ]

rounded off figure? Are you summing integer or float values?
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Grishma Dube:
I've converted it into long but bcoz of that i'm getting rounded off figures. I'm not able to get values after decimal pt.
[ January 29, 2004: Message edited by: Grishma Dube ]

Your original post shows non-decimal values. Why are you expecting decimal point in the answer?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!