English
Forum

Square root without Begrenzung

 

Stefan
Landsberg
Hi,

i want one Program write, that The Quadratwurzel a number accounts.
ABER it should not 6 Nachkommastellen rounds, separate as long as go on To one on Stop clicking.

question:
(How) can the curtail on 6 Nachkommastellen with sqrt() and pow() turn off.

If not goes, then must I me ever a procedure dreamup The that power.
but Please no Fertiglösung post. then learn I nothing.

another question:
is in XProfan 10 The length one floats terminable?
 
08/15/08  
 




Sebastian
Sprenger
Hello Stefan,

question 1:

The functions Sqrt() and Pow() rounds quite nothing. The numbers are just To short displayed.
there's as a commands namens Decimals . with the can you to determine, wieviele Nachkommastellen showing should (on this place verweise I you time on The XProfan-Help ).

question 2:

Floats can in the principle infinite long his, only The undertow. "Rechengenauigkeit" is on 15 to put terminable.
with others Worten: If you a number have, The over 15 Digits long is (alike whether Nachkommastellen or no), can it occur, that bills or Results ex the 16. place inaccurate go.

I geb you time one small example:
declare a!
decimals 35
a!=.333333333333333
print a!
waitinput
by me comes 0.33333333333333298 with etlichen nobodies out. the first 15 Digits voices means, ex the 16. place is correct not plenty.

so, enough learnt?
Greeting, Sebastian
 
Profan² 7.0e, XProfan 9, 11.2a, FreeProfan32
Windows Vista Home Premium 32-Bit, 2.8 Ghz, 4 GB RAM
Windows Me, 1.8 Ghz, 256 MB RAM
08/15/08  
 




Jac
de
Lad

Floats can in the principle infinite long his,

the is correct not...


only The undertow. "Rechengenauigkeit" is on 15 to put terminable.

...and so is a Float NIEMALS infinite long. Also is only one bestimmter area allows (I faith the smallest is 1*10^-43xx or so). small numbers then neither accepted.

there's Algorithms, with them You The root always moreover to charge let can. want You only The 2. root or should each arbitrary n-th root berechenbar his? I could time look, whether I what there have...

Jac
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
08/15/08  
 




Stefan
Landsberg
I Have jetz already a little bit rumprobiert.
somehow komm I do not so correctly. forth because my Program not power I wants.

@sebastian:
thanks for speedy response. but by me can I with decimals but too only To 35 weg. More nachkommastellen go not displayed.

if float only To to 15ten place exactly is it in this case useless for me.

@Jac
i want first only The 2. means The Quadratwurzel to charge. (we've the theme strain in the school, deshlab come so did i on The Idea for so one Program).
I have already on it virtual something To write what a place to the others accounts. the would namely very the I having wished.
i know only not yet where I begin should.

would be it To plenty desires if You (if You so a Algorithmus have) not whom whole code postest separate only Tipps Gibts with whom command the To release is and the groben construction describe? otherwise is the program Yes not of me

@all
I have as ausgabefeld for the Result one multiedit taken.
is the for spending of numbers suitable or there what better?

alas Yes. so sees the from I currently have. it'll but quite nothing calculated. separate only The number from the eingabefeld übernommen:  [...] 
 
08/15/08  
 




Jac
de
Lad
No, No, No! Typischer Anfängerfehler. circa with the Inputs To calculate must You it first of String one Float transfiguring (see "Val()") and to spending in the MultiEdit again in a String (see "Str$()").
Declare
declare in&,out&,btn&,Result$,end%,input$
Window create
windowstyle 575
windowtitle "Quadratwurzel"
window 20,20 - 600,400
usefont "MS Sans Serif",20,0,0,0,0
Window style
in&=create("Edit",%hWnd,"25",5,5,580,20)
btn&=create("button",%hWnd,"Berechnen",250,30,100,30)
out&=create("multiedit",%hWnd,"",5,65,580,-270)

whilenot end%

    WaitInput
    case %key=2 : break

    if clicked(btn&)

        input$=gettext$(in&)
        Result$=Str $(sqrt(Val(input$)))
        settext out&,""
        settext out&,Result$

    endif

endwhile


Kürzer would your Prog so:
Declare
declare in&,out&,btn&,end%
Window create
windowstyle 575
windowtitle "Quadratwurzel"
window 20,20 - 600,400
usefont "MS Sans Serif",20,0,0,0,0
Window style
in&=create("Edit",%hWnd,"25",5,5,580,20)
btn&=create("button",%hWnd,"Berechnen",250,30,100,30)
out&=create("multiedit",%hWnd,"",5,65,580,-270)

whilenot end%

    WaitInput

    if %key=2

        break

    elseif clicked(btn&)

        settext out&,Str $(sqrt(Val(gettext$(in&))))

    endif

endwhile


to that Topic Berechnung:

You can either each place particular to charge let or a number quadrieren and depending on whether tappt im dunkeln To big or To small is always a little bit raise or take away. moreover must You the numbers in Strings Save and each place particular multiplizieren.

Jac
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
08/15/08  
 




Stefan
Landsberg
Hi,

I take for spending the ergebnisses one simple editfeld, but since I in my Program Yes on The available number always The recalculated place dranhängen wants, is it in my opinion unpraktisch and probably too too slow always first whom actually Text with gettext from the editfeld auszulesen, a new digit dranzuhängen, and then again The number with settext in that editfeld To write.
Gibts there a better method or irgendeine message (Gibts a Page/File in the The messages on german declared are) ?
 
08/19/08  
 



wm_copyData could you here help.
 
08/19/08  
 




Stefan
Landsberg
Hello,
thanks first but there somewhere ne Documentation in the The messages verständlich (best german) declared are?
I look with msdn not so correctly. through!
 
08/19/08  
 



clear, XProfan.com Search and google are The aide in such hardship!
 
08/19/08  
 




Stefan
Landsberg
after I jetz finally again little time for XProfan found Have (school claim ne whole crowd time. particularly latein )
place I time again a question:

Why we in the if request no worth on The variable firstpart$ transfer?
I Have already attempts tappt im dunkeln as integer To declarieren. goes neither:
Declare
declare in&,out&,calcbtn&,stopbtn&,Result$,end%,input$
PROC-part

Proc sqrtlong

    Algorithmus to that wander of/ one Quadratwurzel
    Parameters number$, output&, stopbtn&
    declare vorkomma$, div2%, firstsqrt%, firstpart$
    number$=translate $(number$, "," , ".") Dezimalkomma through Dezimalpunkt supplant
    vorkomma$=substr$(number$,1,".") Digits to the comma in vorkomma$ Save
    div2%=Instr(".",st$(substr$(len(vorkomma$ / 2),1,"."))) Verify whether The amount the Digits to the comma straight or ungerade is.

    if div2% = 0

        firstpart$=mid$(vorkomma$,0,2) first 2 Digits from vorkomma$ go in firstpart$ stored
        firstsqrt%=substr$(st$(sqrt(val(firstpart$))), 1 , ".") it becomes The sqrt from firstpart$ formed (remainder becomes omitted)

    else

        firstpart$=mid$(vorkomma$,0,1) first digit from vorkomma$ becomes in firstpart$ stored
        firstsqrt%=substr$(st$(sqrt(val(firstpart$))), 1 , ".") it becomes The sqrt from firstpart$ formed (remainder becomes omitted)

    endif

    locate 4,1 only to that testing what firstpart$ enhält
    print "firstpart:",firstpart$ only to that Test what firstpart$ enhält
    sendmessage(output&,$004A,%hWnd,Addr(firstsqrt%))

endproc

Window create
windowstyle 575
windowtitle "Quadratwurzel"
window 20,20 - 600,125
usefont "MS Sans Serif",20,0,0,0,0
Window style
in&=create("Edit",%hWnd,"25,5",5,5,580,20)
calcbtn&=create("button",%hWnd,"Berechnen",170,30,100,30)
stopbtn&=create("button",%hWnd,"Stop",310,30,100,30)
out&=create("Edit",%hWnd,"",5,65,580,20)

whilenot end%

    WaitInput
    case %key=2 : break

    if clicked(calcbtn&)

        sqrtlong gettext$(in&), out&, stopbtn&

    endif

endwhile

 
09/06/08  
 



The second Parameter of Mid$ must at least 1 his if one objectively ex first position detect would like.
 
09/06/08  
 




Stefan
Landsberg
ahhh,
thanks (Why be I there not self on it come )
 
09/06/08  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

10.313 Views

Untitledvor 0 min.
Sebastian Sprenger10/13/13
Andreas Koch12/20/11

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie