BullyWiiHacks
Welcome dear guest! Very Happy

To start posting and being part of the BWH community, you simply need to register an account or log into an existing one.

If you do not wish to register at all, that's fine but there will be more advertisements. :/

You can probably see and download most content provided for regular members even without an account.

Your contributions will be greatly appreciated though, give it a shot and register today! thumbsup

Join the forum, it's quick and easy

BullyWiiHacks
Welcome dear guest! Very Happy

To start posting and being part of the BWH community, you simply need to register an account or log into an existing one.

If you do not wish to register at all, that's fine but there will be more advertisements. :/

You can probably see and download most content provided for regular members even without an account.

Your contributions will be greatly appreciated though, give it a shot and register today! thumbsup
BullyWiiHacks
Would you like to react to this message? Create an account in a few clicks or log in to continue.
BullyWiiHacks

Gaming, Modding & Programming

Important reminders:

- Click *HERE* for advanced forum search or check out the text field below on the front page for Google before posting
- NO support via private message (use the forum)
- Write meaningful topic titles
Site Translation
Latest topics
» Dropped Out of College to Pursue Web Dev and Life Pursuits in General
Need Help With Java - How do I use Unsigned Integers Empty4/7/2024, 2:34 pm by SnB@BWH

» Bully Made It Into a BIG Video 400K Views
Need Help With Java - How do I use Unsigned Integers Empty4/7/2024, 6:58 am by Bully@WiiPlaza

» Wii Play Tanks
Need Help With Java - How do I use Unsigned Integers Empty3/24/2024, 2:46 pm by helpmeout

» [Bypass Paywalls] (Global) @magnolia1234 - GitLab
Need Help With Java - How do I use Unsigned Integers Empty3/18/2024, 3:55 am by Seth@WiiPlaza

» [Download] Mary Shelley's Frankenhole
Need Help With Java - How do I use Unsigned Integers Empty3/16/2024, 8:29 am by Seth@WiiPlaza

» Completely Custom Modded Controllers (Undetectable)
Need Help With Java - How do I use Unsigned Integers Empty3/5/2024, 1:55 pm by Shadow@BWH

» (Zombies) Drink perks code?
Need Help With Java - How do I use Unsigned Integers Empty3/5/2024, 1:24 pm by Shadow@BWH

» Die Rückkehr zu STEAM und WARFACE
Need Help With Java - How do I use Unsigned Integers Empty3/2/2024, 3:54 am by Seth@WiiPlaza

» First person hand model change?
Need Help With Java - How do I use Unsigned Integers Empty2/28/2024, 4:53 am by Ad3lamac611

» {RELEASE} Field Raider Firefox v1.72 by Seth@WiiPlaza
Need Help With Java - How do I use Unsigned Integers Empty2/21/2024, 8:52 am by naxil

Search
 
 

Display results as :
 


Rechercher Advanced Search

April 2024
MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930     

Calendar Calendar

Country Statistics
Free counters!

You are not connected. Please login or register

Need Help With Java - How do I use Unsigned Integers

4 posters

Go down  Message [Page 1 of 1]

Reclaimer Shawn

Reclaimer Shawn
Code Creator

Hello guys. I have a bit of a problem here... Here's a bit of code and I'll detail what I'm doing:
Code:

        int TID = parseInt(jTextField12.getText());
        int SID = parseInt(jTextField13.getText());
        int PID = parseInt(jTextField3.getText());
        int p1 = (int) Math.floor(PID / 65536);
        int p2 = (PID % 65536);
        int res = TID ^ SID ^ p1 ^ p2;
        System.out.println("TID xor SID xor p1 xor p2 =" +res);
        System.out.println(TID + " " + SID + " " + PID + " " + p1 + " " + p2);
        if(res <  8 {
        shinypkmnyn = "Pokemon is Shiny!";
        }
        else {
        shinypkmnyn = "Pokemon is not Shiny!";
        }
        JOptionPane.showMessageDialog(frame,"Your PID generates a " +shinypkmnyn);

My problem is that whenever it goes to parse the Integer for a value over 2147483647, it'll show up as negative, and then that negative number gets XOR'd instead of the original number (e.g. 4294967293)
First, it needs to divide said number... So, math.floor(4294967293 / 65536) That should round said number down. However, considering it's over 2147483647, it just divides the negative, rounds, and finished.
Trainer ID and SID is then XOR'd, and then it XORs that together with the next two parts of the code, being this: -3 xor 0
Instead of doing this : 65535 xor 65533
The result of that calculation, if less than 8, results in a shiny pokemon. My calculator will work for the 1st 2147483648 values, but I don't know about the rest... Will my program still report if the Pokemon is Shiny correctly?
Found my math here:
http://bulbapedia.bulbagarden.net/wiki/Personality_value

Remember, my calculation is 0 xor 0 xor 65535 xor 65533
But it does this: 0 xor 0 xor -3 xor 0



Last edited by Reclaimer Shawn on 7/29/2016, 1:23 pm; edited 2 times in total

SnB@BWH

SnB@BWH
Admin & Writer

I'm no good with code, but didn't you forget to say what "res" should be less than? You said "If res is less than..." and then told it what it should do. You can't say the word "if" without including what you want it to do before it goes through a true or false, calculation or comparisn stage which then leads to another if or the results based on whether the statement was any of the aforementioned.

Hope this helps! Smile


_________________
Need Help With Java - How do I use Unsigned Integers Simple10

Need Help With Java - How do I use Unsigned Integers LSTjSyDDiscord: SnB_BWH

Click HERE to earn free bitcoin, litecoin, dogecoin, and dash!

Win Free Bitcoins every hour!

Reclaimer Shawn

Reclaimer Shawn
Code Creator

Crap! Forgot to copy/paste my result... Mad Res must be < 8
I guess a better question is how do I use unsigned integers if possible, as this will only work with an unsigned 32 Bit number.
EDIT: Can also confirm it works with every number below 2147483648. Everything else it is hideously inaccurate...

SnB@BWH

SnB@BWH
Admin & Writer

Apparently, from what I just Googled, Java doesn't have any way to declare unsigned ints. You have to use long to store large values, but there's no way to exclude negative values. I Java SE 8 and later, you can use static methods like compareUnsigned and divideUnsigned to deal with 32 bit unsigned integers.


_________________
Need Help With Java - How do I use Unsigned Integers Simple10

Need Help With Java - How do I use Unsigned Integers LSTjSyDDiscord: SnB_BWH

Click HERE to earn free bitcoin, litecoin, dogecoin, and dash!

Win Free Bitcoins every hour!

Reclaimer Shawn

Reclaimer Shawn
Code Creator

shitnbitch@BWH wrote:Apparently, from what I just Googled, Java doesn't have any way to declare unsigned ints. You have to use long to store large values, but there's no way to exclude negative values.
Which is what I've been seeing too... I might have to scrap the shiny calculator, but IVs are calculated bit-by-bit(so whether it's stored as signed or unsigned won't matter) At least PID results will actually do something.

Bully@WiiPlaza

Bully@WiiPlaza
 
 

Check out this:

Code:
int overflowedInteger = Integer.MAX_VALUE + 1;
long unsignedInt = getUnsignedInt(overflowedInteger);
System.out.println(unsignedInt);

Output:
Code:
2147483648

Method used:
Code:
public static long getUnsignedInt(int number)
{
 return number & 0xFFFFFFFFL;
}

To sum up, you have to use the next bigger datatype to go "unsigned" with the previous so shitnbitch is right. Smile

Also please don't say JavaScript. It's Java. Don't be a skid. There is a HUGE difference.

Need Help With Java - How do I use Unsigned Integers Segue-blog-java-vs-javascript


_________________
Need Help With Java - How do I use Unsigned Integers YBjg74I

wundrweapon

wundrweapon

Java doesn't have support for unsigned numerical data types. If you need an int that goes beyond Integer.MAX_VALUE then just use a long. If you absolutely positively MUST use an unsigned value, make your program in C#

I'm serious

C# is very similar to Java, so it's really easy for Java programmers to learn. It's in every way better, too - signed data types, built-in .NET support, operator overloading, etc


_________________
Feel free to PM me for whatever reason. You can also find me on Steam or YouTube.

Reclaimer Shawn

Reclaimer Shawn
Code Creator

Hey Bully! I implemented the code, and after revising it to my needs, it works! It now is able to get whether or not a Pokemon will be Shiny 100% of the time. Thank you Bully! Also, sorry for being a skid! Wink

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum