![]() |
how to print floating point numbers
Programs computes the roots of Quadratic equations: Ax^2+Bx+C=0,it doesnot print the fractional part of roots.
How to print fractional part ? finit fstcw controlWd or controlWd,0000110000000000b fldcw controlWd output prompt1 output prompt2 input string,40 atod string mov A,eax output prompt3 input string,40 atod string mov B,eax output prompt4 input string,40 atod string mov C1,eax fild C1 ;value of C in ST0 fild A ;value of A in ST1 fmul ;A*C and in ST0 fild no ;4 in ST0 fmul ;4*A*C and in ST0 fild B ;B in ST0 fild B ;B in ST1 fmul ;B*B in ST0 fsubr ;B*B - ( 4*A*C) and in ST0 fsqrt ;Determinant( D ) = SQRT( B^2-4AC) and in ST0 fist no3 ;store D mov eax,no3 ;store D in eax fild B ;B in ST0 fchs ;-B in ST0 fsubr ;-B-D in ST0 fild no4 ;2 in ST0 fild A ;A in ST0 fmul ;2*A fdiv ;-B-D/2*A fist no5 ;store first root mov ebx,no5 ;store first root in ebx fild no3 ;D in ST0 fild B fchs fadd fild no4 fild A fmul fdiv fst no10 fist no7 mov ecx,no7 dtoa no6,ebx output print2 dtoa no9,ecx output print3 |
EAX, you have 14 posts. One would presume that you have read the forum's rules and "How to Post..." threads just as a courtesy to your fellow members. To fit in, donchano. Read them again, looking out for the part that mentions using 'code tags.'
|
How to print floting point numbers ?
Thanks, DaWei for pointing it out .
This Program computes the roots of Quadratic equations: Ax^2+Bx+C=0,it doesnot print the fractional part of roots. How to print fractional part ? :
finit |
It's probably just my age and inactivity showing, but your code looks strange to me. What assembler are you using, and are there macros floating about that I can't see?
|
I am using ML assembler from MASM 6.1 , i am not using any macros.
I am just using FPU 8 registers and only Floating point instructions to accomplish the task. |
Okay, I'm going to unashamedly admit that I never saw a MASM with dtoa and output instructions. I'm going to leave you to the tender mercies of someone else. I suspect the conversion and output, though.
|
| All times are GMT -5. The time now is 6:41 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC