Jump to content
Sign in to follow this  
E1M1

90 (float) isn't same as 90 (int)? Atleast not for autoit. It thinks that 90 that is result of aCos is > than just 90.

Recommended Posts

E1M1

I am supprised that in 1st test value of $__ is 90 with out any or. it's exactly 90 but $__ = 90 returns false. Does anyone know how what causes this problem in my test? for somereason it thinks that $__ is greater than 90 but when you look at console output you can clearly see that it isn't.

You can run code below.

MsgBox(0, 0, Test("1 0 2 0 1 2"))
;MsgBox(0, 0, Test("3 0 4 2 5 0"))
;MsgBox(0, 0, Test("6 0 7 0 8 2"))
;~ $TriangleCoords = "x1 xy x2 y2 x3 y3"
;~ Angles: If 1 of the angles are:
;         < 90 acute angle
;           > 90 obtuse angle
;         = 90 square corner
Func Test($TriangleCoords)
    ConsoleWrite(@CRLF)

    $Triangle = $TriangleCoords
    $Triangle = StringSplit($Triangle, " ")

    Dim $A[2], $B[2], $C[2], $AB[2], $BC[2], $CA[2]

    $A[0] = Number($Triangle[1])
    $A[1] = Number($Triangle[2])

    $B[0] = Number($Triangle[3])
    $B[1] = Number($Triangle[4])

    $C[0] = Number($Triangle[5])
    $C[1] = Number($Triangle[6])

    $AB[0] = $B[0] - $A[0]
    $AB[1] = $B[1] - $A[1]

    $BC[0] = $C[0] - $B[0]
    $BC[1] = $C[1] - $B[1]

    $CA[0] = $A[0] - $C[0]
    $CA[1] = $A[1] - $C[1]

    $A = Sqrt($AB[0] ^ 2 + $AB[1] ^ 2)
    $B = Sqrt($BC[0] ^ 2 + $BC[1] ^ 2)
    $C = Sqrt($CA[0] ^ 2 + $CA[1] ^ 2)

    $pi = 3.14159265358979323846264338327950288419716939937510
    $radToDeg = 180 / $pi

    $_ = ACos(($B ^ 2 + $C ^ 2 - $A ^ 2) / (2 * $B * $C)) * $radToDeg
    $__ = ACos(($A ^ 2 + $C ^ 2 - $B ^ 2) / (2 * $A * $C)) * $radToDeg
    $___ = ACos(($A ^ 2 + $B ^ 2 - $C ^ 2) / (2 * $A * $B)) * $radToDeg

    ConsoleWrite($_ & @CRLF)
    ConsoleWrite($__ & @CRLF)
    ConsoleWrite($___ & @CRLF)

    MsgBox(0,$__,$__ = 90)

    ;If $_ = 90 or $__ = 90 Or $___ = 90 Then Return "Täisnurk"
    ;If $_ > 90 or $__ > 90 Or $___ > 90 Then Return "nürinurk"

EndFunc   ;==>Test

edited

Share this post


Link to post
Share on other sites
E1M1

I figured that when I change $__ = 90 to String($__) = String(90) then it returns true


edited

Share this post


Link to post
Share on other sites
bogQ

you can use string comparation

$__ == 90

or

Int($__) = 90

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
E1M1

just wondering why it doesnt work with numbric versions of variables? Is it because 1 is float and other is int?


edited

Share this post


Link to post
Share on other sites
Yashied

Because ACos(...) * 180 / 3.14... <> 90 and Pi <> 3.14159265358979323846264338327950288419716939937510. Am I right? For a correct comparison of the values ​​you need to round a float value with an accuracy of its type. For the FLOAT type it should be about seven digits, DOUBLE - about 15 digits.

MsgBox(0, $__, Round($__, 7) = 90)

Share this post


Link to post
Share on other sites
happytc

Try this:

$Num = 1
For $i = 0 To 100
$Num += 0.1
ConsoleWrite($Num & @CRLF)
Next
Edited by happytc

Share this post


Link to post
Share on other sites
UEZ

Instead of using the long floating number for pi just use

Const $pi = ACos(-1)

instead.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×