Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
Do While Loop exits despite condition being met

I have the following code (where generateGaussian is a function previously defined elsewhere):

function varInstance(stdev, scaling, shift){
gg = -999;
 do {
    gg = generateGaussian(0, stdev);
 }
 while (-3 > gg > 3);
 return ((gg * scaling) + shift);
}

What I want it to do is to produce a value between -3 and +3 But I notice that occasionally it gives me values >3. I have not not noticed it giving me values <-3, though. What am I doing wrong and how can I change it to limit the output to the -3...3 range?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!