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 7039909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:51:18+00:00 2026-05-28T01:51:18+00:00

What technique would you use to make the test below pass? Cheers, Berryl [Test]

  • 0

What technique would you use to make the test below pass?

Cheers,
Berryl

    [Test]
    public void PercentageToSplit() {
        for (int i = 1; i < 20; i++) {
            decimal ratio = 1m / i;
            Console.WriteLine(ratio);

            var splitCount = (int)Math.Floor(1 / ratio); // *** this won't do
            Console.WriteLine(splitCount );

            Assert.That(splitCount, Is.EqualTo(i));
        }

1 becomes 1
0.5 becomes 2
0.3333333333333333333333333333 becomes 3
0.25 becomes 4
0.2 becomes 5
0.1666666666666666666666666667 becomes 5
Test 'PercentageToSplit' failed: 
  Expected: 6
  But was:  5
  • 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-28T01:51:19+00:00Added an answer on May 28, 2026 at 1:51 am

    Your test passes if you change Math.Floor to Math.Round.

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

Sidebar

Related Questions

What technique should we use to make the httpsession object not loaded heavily with
Which techniqes would you use to implement a search for contents in a column
Do you know any implementation / technique which would provide similar behavior as Viewstate
I would like to know what's the best technique to do single sign-on in
I would like to make an app on android which sends MIDI messages over
I am trying to make an app which use displacement map for 3d effect.
Just as the title said. What ways do you use to test your own
I would like to use Bitmaps in my Actionscript games. For me this represents
I've been test-infected for a long time now, but it would seem the majority
GNU/Make manual §5.7 states the following: 5.7 Recursive Use of make Recursive use of

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.