Sign in to follow this  
Followers 0
Phaethon

Rounding? Help Please.

5 posts in this topic

If (1/3)*3 = 1 Then
    $num = (1/3)*3
    MsgBox(0, "YAY",$num)
Else
MsgBox(0,"","Fail")
EndIf

Why is it returning 1? Is some sort of rounding occurring?


Coder's Helper >> Here[center][/center]

Share this post


Link to post
Share on other sites



er... O_O

even i child of 10 can solve this one :(

well 1/3 equals ~0.3333 and that number * 3 = 1

The if statements looks if the result equals 1, and yes it does.

then it shows it in a msgbox.

To make my post a little more useful i will say a more simple way to form the code you have:

$num = (1/3)*3

if $num = 1 then
 msgbox(0, "YAY", $num)
else
 msgbox(0, "", "Fail")
endif

you see that you used too many (1/3)*3blabla, instead you could've written 1x the $num var, and call THAT up.

costed you less typing :)

just the info

immense

Share this post


Link to post
Share on other sites

This is actually a very interesting mathematical question. The above is the proof that 0.999999... is equal to 1. Why? Because 1/3 is not 0.333 it's 0.333... (notice the dots) and that times 3 is 0.999... which is equal to 1 ( since 1/3 = 0.333 and 1/3*3 is equal to one).


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

This is actually a very interesting mathematical question. The above is the proof that 0.999999... is equal to 1. Why? Because 1/3 is not 0.333 it's 0.333... (notice the dots) and that times 3 is 0.999... which is equal to 1 ( since 1/3 = 0.333 and 1/3*3 is equal to one).

interesting that you would bring that up, I was actually trying to use this as a sort of "joke" to disprove that :)

@Immense - Thanks for your attempt to help me, but that is not at all relevant sadly. I know how to code this lol, it isn't for anything "practical" simply a demonstration.


Coder's Helper >> Here[center][/center]

Share this post


Link to post
Share on other sites

interesting that you would bring that up, I was actually trying to use this as a sort of "joke" to disprove that :)

You know I had a feeling you were doing that :(


Broken link? PM me and I'll send you the file!

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  
Followers 0