Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Help] Math in Java

Featured Replies

My account needs to keep 4.3m gold in the inventory. The amount of gold before muling is a number above 4.3m. 

So I used the equation

 

amount in inventory - 4.3m = amount to trade


So in my code I put 

long x = getInventory().getAmount(995);

long amountToTrade = x - 4300000;

 

Now in my mule code, I put

trade.offer(995, amountToTrade);

 

Sadly this does not work even though all the math makes sense. 
I know the string requires an int but I cannot use int when i am getting the amount in the inventory. 

Any help or suggestions would be greatly appreciated :)

not sure if this is what you're looking for..

 

cast long to int

trade.offer(995, Math.toIntExact(amountToTrade));

this will throw ArithmeticException if overflow (amountToTrade greater than 2,147,483,647)

Longs are not commonly used for this type of thing. Doubles would be easier. Also you can use Integer.ParseInt(input) to cast anything to an int, except I think BigInts. Which you should never need for OSRS

  • Author
1 hour ago, Stimpack said:

not sure if this is what you're looking for..

 

cast long to int


trade.offer(995, Math.toIntExact(amountToTrade));

this will throw ArithmeticException if overflow (amountToTrade greater than 2,147,483,647)

Thanks it worked!

Yeah I was gonna say, an int should be fine so long as its under 2,147,483,647 gp which I would assume you don't make before trading to the mule; otherwise that'd be hella impressive :D

13 minutes ago, Magarac said:

Yeah I was gonna say, an int should be fine so long as its under 2,147,483,647 gp which I would assume you don't make before trading to the mule; otherwise that'd be hella impressive :D

That is the max cash stack on rs so he cant really trade more than it

Just now, Tom said:

That is the max cash stack on rs so he cant really trade more than it

:kappa: I feel dumb. Completely forgot about RS's own limits.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.