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

  • Home
  • SEARCH
  • 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 452263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:03:18+00:00 2026-05-12T22:03:18+00:00

UPDATE : This question is not homework. And not waterproof apparantly… I wanted a

  • 0

UPDATE :

This question is not homework. And not waterproof apparantly…
I wanted a discussion about internal representation.
Of course : the add1000 ought to add 1000.

**Please answer in the spirit of this question… Making this waterproof would make this question longer without no reason.. **
You can beat a pure decimal representation
Changing internal representation in runtime
UPDATE 2 : see

Create a type that implements this interface :

interface INumber
    {
        void add1000();
        void SetValue(decimal d);
        decimal GetValue();         
    }

so that i iterates as fast as possible from 0 to 10 billion (american billion, so till 10e9) in this for loop :

private static void DoSomeAdding(INumber n)
        {
            Debug.Assert(n.GetValue()==0);

            for (long i=0; i<10000000000; i += 1000)
            {
                n.add1000();
            }

            Debug.Assert(n.GetValue() == 10000000000);

        }

So you can call it as :

DoSomeAdding(new YourNumberClass());
  • 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-12T22:03:18+00:00Added an answer on May 12, 2026 at 10:03 pm

    Like Anton’s solution, but with a bit more care 🙂 Oh, and I’ve changed the names to be more .NET-like.

    public Number : INumber
    {
        private decimal value = 0m;
        private int thousands = 0;
    
        public void Add1000()
        {
            thousands++;
        }
    
        void SetValue(decimal d)
        {
            value = d;
            thousands = 0;
        }
    
        decimal GetValue()
        {
            // Careful of the overflow... (do multiplication in decimal)
            value += thousands * 1000m;
            thousands = 0;
            return value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: .NET Controls: Why aren’t all calls thread-safe? This question is not about
UPDATE: This isn't about getting it to compile. The question is, why does the
Duplicate of this question . update - This is not an exact duplicate. See
UPDATE: This question is out of date, but left for informational purposes. Original Question
Update: This question was an epic failure, but here's the working solution. It's based
Update: This question is a duplicate of Are there any programming languages targeting PHP,
Sorry for the double post, I will update this question if I can't get
UPDATE (spoiler): This question is answered (see David Carlisle answere below) and it looks
UPDATE : Since this question is getting some views, I figured I'd better highlight
Update: See the bottom of this question for a C# workaround. Hi there, Consider

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.