Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6807697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:51:50+00:00 2026-05-26T19:51:50+00:00

I have some variables, which all contain numbers, and they are all parseFloat’s. In

  • 0

I have some variables, which all contain numbers, and they are all parseFloat’s.

In the end, all the parseFloat’s are calculated into one variable, and from that variable, I need some function, that settles the specific number, into every fifty(50).. So if the specific number is 163, it needs to be settled to 150. and if its 243, it needs to be settled to 200..

This is actually working, but there is a problem tho..
The browser freezes and tells the script are LOOPing ?? I’m thinking it’s because the variable betalTotal, is containing a comma number ?? like 6.5 ?

This is what I’m having so far:

iAlt = 0;

iAlt = maxregning - pakkerTotal - betalTotal;

//parseFloat(iAlt);
/* - THIS AINT WORKING 
if(betalTotal == 6.5){
    betalTotal.val(betalTotal.val().replace('6.5', '6,5'))
}*/

while(iAlt % 50 != 0){
    iAlt--;
}
$('#sk').text(iAlt);

Does anyone know a solution for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:51:51+00:00Added an answer on May 26, 2026 at 7:51 pm

    Divide the value by 50, round it, and multiply by 50:

    iAlt = Math.floor(iAlt / 50) * 50;
    

    (Your original method would also work if you rounded the value before the loop, but the loop is not needed at all this way.)

    This will always round down, i.e. 243 to 200. If you want to round to the closest, i.e. 243 to 250, you would use Math.round instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a url which has some get variables in it like: domain.com/recover?email=my@email.com&token=abc123 inside
I have an object which straight forward instance variables. Some are NSString, some are
I have a bunch of variables I want to display of which some are
In my init I have set some variables and one animate that uses those
I have class MasterData whose instances contain some general information about all possible gadgets.
I have a list of dataframes for which I am certain that they all
I have this code Math.min(someVariable, 500)) I also have some divs which I have
I have some variables inside a template and I don't know where I assigned
I have some variables like these: a(1)=00:26:00 a(2)=744:32:00 a(3)=8040:33:00 I want to convert them
Basically I have some variables that I don't want to preinitialize: originalTime = None

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.