Results 1 to 5 of 5
- 06-17-2010, 03:51 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 2
- Rep Power
- 0
really quick question for beginner
hey there, im making a little program that converts celcius to farenheit blah blah not important
heres the situation:
celcius = c
farenheit = f
(bot c and f are doubles)
c = (5/9) * (f-32)
weird thing is using that equation doesnt work and my value for C will be zero
i know it a problem with 5/9 because if i use someone like 10/5 itll work just fine. so whats the problem with 5/9? is division whacky in java or something?
-
You are stumbling against int division. You see an int divided by an int will result in an int, with rounding and all. Convert one to a double:
c = (5.0/9.0) * (f-32)
- 06-17-2010, 04:06 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 2
- Rep Power
- 0
mmmother F! so simple! thanks!
-
You're quite welcome. Welcome to the forum by the way!
- 06-17-2010, 04:14 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Really quick question
By shadycharacter in forum New To JavaReplies: 2Last Post: 04-22-2010, 10:06 PM -
Quick question
By sAntA199 in forum New To JavaReplies: 2Last Post: 12-09-2009, 03:01 AM -
quick question
By vouslavous in forum Java AppletsReplies: 4Last Post: 04-24-2009, 08:35 PM -
Hello everyone! quick question.
By irishhokie in forum New To JavaReplies: 5Last Post: 04-03-2009, 04:13 AM -
Quick Question
By Spenc in forum New To JavaReplies: 3Last Post: 09-22-2008, 02:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks