Click here to Skip to main content
15,907,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionsqrt() pow() fabs() do not work Pin
Member 337533412-Feb-09 19:23
Member 337533412-Feb-09 19:23 
AnswerRe: sqrt() pow() fabs() do not work Pin
Cedric Moonen12-Feb-09 20:18
Cedric Moonen12-Feb-09 20:18 
GeneralRe: sqrt() pow() fabs() do not work Pin
Nishad S12-Feb-09 21:33
Nishad S12-Feb-09 21:33 
GeneralRe: sqrt() pow() fabs() do not work Pin
Cedric Moonen12-Feb-09 21:37
Cedric Moonen12-Feb-09 21:37 
GeneralRe: sqrt() pow() fabs() do not work Pin
David Crow13-Feb-09 2:51
David Crow13-Feb-09 2:51 
GeneralRe: sqrt() pow() fabs() do not work Pin
Chris Losinger13-Feb-09 4:17
professionalChris Losinger13-Feb-09 4:17 
GeneralRe: sqrt() pow() fabs() do not work Pin
Alexander M.,15-Feb-09 7:37
Alexander M.,15-Feb-09 7:37 
GeneralRe: sqrt() pow() fabs() do not work Pin
Chris Losinger13-Feb-09 4:16
professionalChris Losinger13-Feb-09 4:16 
the compiler will optimize that multiplication away.

int value = rand();
int result1 = (int)fabs(value*1.0); 
printf("%d, %d\n", result1, result1);


VC6, release mode gives the following assembly:

; 10   : 	int value = rand();

	call	_rand

; 11   : 	int result1 = (int)fabs(value*1.0); 

	mov	DWORD PTR -4+[esp+4], eax
	fild	DWORD PTR -4+[esp+4]
	fabs
	call	__ftol

; 12   : 	printf("%d, %d\n", result1, result1);

	push	eax
	push	eax
	push	OFFSET FLAT:??_C@_07JPPP@?$CFd?0?5?$CFd?6?$AA@ ; `string'
	call	_printf


no fmul.

if you do this:
int value = rand();
int result1 = (int)fabs((double)value); 
printf("%d, %d\n", result1, result1);


you get this:
; 10   : 	int value = rand();

	call	_rand

; 11   : 	int result1 = (int)fabs((double)value); 

	mov	DWORD PTR -4+[esp+4], eax
	fild	DWORD PTR -4+[esp+4]
	fabs
	call	__ftol

; 12   : 	printf("%d, %d\n", result1, result1);

	push	eax
	push	eax
	push	OFFSET FLAT:??_C@_07JPPP@?$CFd?0?5?$CFd?6?$AA@ ; `string'
	call	_printf



exactly the same.


GeneralRe: sqrt() pow() fabs() do not work Pin
Nishad S15-Feb-09 17:29
Nishad S15-Feb-09 17:29 
QuestionAlternative for CMap in MFC Pin
Ramasani12-Feb-09 18:30
Ramasani12-Feb-09 18:30 
AnswerRe: Alternative for CMap in MFC Pin
Cedric Moonen12-Feb-09 20:19
Cedric Moonen12-Feb-09 20:19 
GeneralRe: Alternative for CMap in MFC Pin
Arman S.12-Feb-09 20:49
Arman S.12-Feb-09 20:49 
GeneralRe: Alternative for CMap in MFC Pin
Ramasani12-Feb-09 22:11
Ramasani12-Feb-09 22:11 
GeneralRe: Alternative for CMap in MFC Pin
Arman S.12-Feb-09 22:33
Arman S.12-Feb-09 22:33 
QuestionHow to get the available ports? Pin
AnithaSubramani12-Feb-09 18:15
AnithaSubramani12-Feb-09 18:15 
AnswerRe: How to get the available ports? Pin
SandipG 12-Feb-09 19:53
SandipG 12-Feb-09 19:53 
AnswerRe: How to get the available ports? Pin
David Crow13-Feb-09 3:03
David Crow13-Feb-09 3:03 
QuestionObtaining the HWND of a window Pin
hxhl9512-Feb-09 17:53
hxhl9512-Feb-09 17:53 
QuestionRe: Obtaining the HWND of a window Pin
«_Superman_»12-Feb-09 18:03
professional«_Superman_»12-Feb-09 18:03 
AnswerRe: Obtaining the HWND of a window Pin
hxhl9512-Feb-09 18:11
hxhl9512-Feb-09 18:11 
AnswerRe: Obtaining the HWND of a window Pin
SandipG 12-Feb-09 20:04
SandipG 12-Feb-09 20:04 
AnswerRe: Obtaining the HWND of a window Pin
Stuart Dootson12-Feb-09 21:59
professionalStuart Dootson12-Feb-09 21:59 
GeneralRe: Obtaining the HWND of a window Pin
hxhl9513-Feb-09 12:59
hxhl9513-Feb-09 12:59 
QuestionEM_REPLACESEL order of API's Pin
ForNow12-Feb-09 17:37
ForNow12-Feb-09 17:37 
QuestionC++ Logging: Any recommendations? Pin
gvanto12-Feb-09 16:36
gvanto12-Feb-09 16:36 

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.