Click here to Skip to main content
15,908,172 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Compare/Convert Float to Text Pin
David Crow23-Aug-10 7:24
David Crow23-Aug-10 7:24 
GeneralRe: Compare/Convert Float to Text Pin
mohit`1223-Aug-10 7:31
mohit`1223-Aug-10 7:31 
GeneralRe: Compare/Convert Float to Text Pin
Maximilien23-Aug-10 7:53
Maximilien23-Aug-10 7:53 
GeneralRe: Compare/Convert Float to Text Pin
mohit`1223-Aug-10 9:14
mohit`1223-Aug-10 9:14 
GeneralRe: Compare/Convert Float to Text Pin
englebart24-Aug-10 4:11
professionalenglebart24-Aug-10 4:11 
GeneralRe: Compare/Convert Float to Text Pin
Iain Clarke, Warrior Programmer23-Aug-10 7:57
Iain Clarke, Warrior Programmer23-Aug-10 7:57 
GeneralRe: Compare/Convert Float to Text Pin
mohit`1223-Aug-10 9:16
mohit`1223-Aug-10 9:16 
GeneralRe: Compare/Convert Float to Text Pin
Iain Clarke, Warrior Programmer23-Aug-10 9:36
Iain Clarke, Warrior Programmer23-Aug-10 9:36 
mohit`12 wrote:
I didn't get your code why would i use epsilon ?


You yourself brought up the problem of floating point numbers being not perfect - if you read some of the links given you, you will realise that testing for equality is basically a waste of time. Digital computers simply do not do perfect representations of non-integers. Unless you're very lucky, and it's 1/(2^n). Two numbers can be reeeeeeeally close, and not equal. The simple fact you asked your original question shows that you know this already.

mohit`12 wrote:
and it has to be FLOAT


So change double to float. Or whatever FLOATs your boat. Not the hardest of challenges!

Iain.

ps, My code will also cope (as it should) with negative floating values.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!

GeneralRe: Compare/Convert Float to Text Pin
hairy_hats24-Aug-10 2:50
hairy_hats24-Aug-10 2:50 
GeneralRe: Compare/Convert Float to Text Pin
Iain Clarke, Warrior Programmer24-Aug-10 3:03
Iain Clarke, Warrior Programmer24-Aug-10 3:03 
GeneralRe: Compare/Convert Float to Text PinPopular
Aescleal23-Aug-10 7:58
Aescleal23-Aug-10 7:58 
GeneralRe: Compare/Convert Float to Text Pin
mohit`1223-Aug-10 9:17
mohit`1223-Aug-10 9:17 
GeneralRe: Compare/Convert Float to Text [modified] Pin
Aescleal23-Aug-10 10:21
Aescleal23-Aug-10 10:21 
GeneralRe: Compare/Convert Float to Text Pin
Tim Craig23-Aug-10 9:30
Tim Craig23-Aug-10 9:30 
AnswerRe: Compare/Convert Float to Text Pin
Niklas L23-Aug-10 8:00
Niklas L23-Aug-10 8:00 
GeneralRe: Compare/Convert Float to Text Pin
mohit`1223-Aug-10 9:18
mohit`1223-Aug-10 9:18 
GeneralRe: Compare/Convert Float to Text Pin
Niklas L23-Aug-10 10:08
Niklas L23-Aug-10 10:08 
GeneralRe: Compare/Convert Float to Text Pin
fasked23-Aug-10 18:48
fasked23-Aug-10 18:48 
QuestionRe: Compare/Convert Float to Text Pin
Niklas L23-Aug-10 19:37
Niklas L23-Aug-10 19:37 
AnswerRe: Compare/Convert Float to Text [modified] Pin
fasked23-Aug-10 19:40
fasked23-Aug-10 19:40 
GeneralRe: Compare/Convert Float to Text Pin
Niklas L23-Aug-10 20:23
Niklas L23-Aug-10 20:23 
AnswerRe: Compare/Convert Float to Text PinPopular
Luc Pattyn23-Aug-10 8:42
sitebuilderLuc Pattyn23-Aug-10 8:42 
GeneralRe: Compare/Convert Float to Text Pin
mohit`1223-Aug-10 9:20
mohit`1223-Aug-10 9:20 
GeneralRe: Compare/Convert Float to Text Pin
Luc Pattyn23-Aug-10 9:28
sitebuilderLuc Pattyn23-Aug-10 9:28 
AnswerRe: Compare/Convert Float to Text Pin
Jeff Archer24-Aug-10 4:02
Jeff Archer24-Aug-10 4:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.