Sign in to follow this  
Followers 0
rcmaehl

[Solved] I Need Math Help

11 posts in this topic

#1 ·  Posted (edited)

Note: math is zero-based as it's on a grid

1. I have a 16x16 grid of squares (256 total)

2. Within each square are smaller squares (256 total) that are also arranged 16x16

3. I need to two numbers and covert them to determine which large square and which small square should be colored

4. I need a formula that would do this:

Data:

(Num1.Num2) = (x,y)

0.0 = 0,0
0.1 = 1,0
0.2 = 2,0
...
0.16 = 0,1
0.17 = 1,1
0.18 = 2,1
...
16.0 = 0,16
...
16.16 = 0,17
16.17 = 1,17
16.18 = 2,17
...
255.255 = 255,255
Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites



You'll need to work with integers and Mod(), as in $value = Mod($input, 16)

Your examples are wrong AFAICT.

Are you really going to try working with 16.17 (floating point values)? If so, you setup yourself for surprises.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

The 2 numbers are part of an IP address. The . is the separator of the 2 numbers. I should of specified that.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

As stated in your other thread, there are no valid IP addresses that start with "0.x" and there are also no valid IP addresses that start with anything above "223.x" so you wouldn't need to include those in your grid. There are also a lot of other IP addresses that aren't valid that don't need to be included, because you'll never see them. If you are doing this for Internet IP addresses, and not LAN IP addresses, you can eliminate all of the private IP address ranges from the list as well, because if you ever saw one of them in an internet address it's an error.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

As stated in your other thread, there are no valid IP addresses that start with "0.x" and there are also no valid IP addresses that start with anything above "223.x" so you wouldn't need to include those in your grid. There are also a lot of other IP addresses that aren't valid that don't need to be included, because you'll never see them. If you are doing this for Internet IP addresses, and not LAN IP addresses, you can eliminate all of the private IP address ranges from the list as well, because if you ever saw one of them in an internet address it's an error.

I'll add that after the formula for this. It would most likely be easier.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It has been more than 24 hours. I still need help.

P.S. This is a "bump"

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

What have you coded so far? Can you post your script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Here ya go. Next time I'd like to see a little code from you first.

For $i = 0 To 255
    For $j = 0 To 255
        $x = Mod($j, 16)
        $y = Floor($j / 16) + Mod($i * 16, 256)
        ConsoleWrite($i & "." & $j & " = " & $x & "," & $y & @CRLF)
    Next
Next

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites

Hah. This thread showed up as the latest topic in General help and support as "I Need Mat..."

Share this post


Link to post
Share on other sites

Here ya go. Next time I'd like to see a little code from you first.

For $i = 0 To 255
    For $j = 0 To 255
        $x = Mod($j, 16)
        $y = Floor($j / 16) + Mod($i * 16, 256)
        ConsoleWrite($i & "." & $j & " = " & $x & "," & $y & @CRLF)
    Next
Next

I actually was just about to upload it. I just noticed that your math is wrong, but I think I understand what I have to do. Thanks ;)

Hah. This thread showed up as the latest topic in General help and support as "I Need Mat..."

Heh.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

I just noticed that your math is wrong

I hate it when that happens. Try this one.

For $i = 0 To 255
    For $j = 0 To 255
        $x = Mod(Mod($j, 16) + (Mod($i, 256) * 16), 256)
        $y = Floor($j / 16) + 16 * Floor($i / 16)
        ConsoleWrite($i & "." & $j & " = " & $x & "," & $y & @CRLF)
    Next
Next

Thanks ;)

Glad to help.

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

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