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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:34:13+00:00 2026-05-26T17:34:13+00:00

I am testing a matrix if it has a prime number in every line.

  • 0

I am testing a matrix if it has a prime number in every line.

The MR means that it should use the Miller Rabin algorithm. If its false it simply tries the divisors up to sqrt(n). Vansor is true if it has found a prime in every checked row, vanoszlop is true if it has found a prime in the actually checked row.

My question is: Is it possible to save the memory by not creating both the int and BigInteger values only if the tryParse is true? I mean something like

if (int.tryParse(akt, out new int szam))

Is something like this possible? (and how much memory does a BigInteger take when its not signed?)

    akt = Console.ReadLine();
    int szam; BigInteger szambig;

    if (int.TryParse(akt, out szam))
    {
       if (MR)  {
          if (MilRab(szam))
          { vansor = true; vanoszlop = true; } }

          else if (Prim(szam))
          { vansor = true; vanoszlop = true; }
    }
    else if (BigInteger.TryParse(akt, out szambig))
    {
       if (MR) {
          if (MilRab(szam))
          { vansor = true; vanoszlop = true; } }

       else if (Prim(szam))
       { vansor = true; vanoszlop = true; }
    }
  • 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-26T17:34:14+00:00Added an answer on May 26, 2026 at 5:34 pm

    I’m not 100% sure on how .Net IL optimizes memory, but in general local “value” type (as opposed to “reference” types) are kept on the stack. IE, you would only save the ~4 bytes that an integer takes up by not instantiating it, and only for the lifetime of that one call. Once you exit the function, the stack is cleared.

    Structures are “value” types, and are also placed on the stack. They reserve memory for all other value types & reference pointers as needed. The size of a BigInteger is the same whether or not “Signed” is true or false.

    I suppose my real question is: why the memory obsession? With the code example you have, you’ll take a few dozen bytes of memory that will all be freed up when the method exits.

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

Sidebar

Related Questions

I have this sprite rotating algorithm (its poorly named and just used for testing).
Unit testing sounds great to me, but I'm not sure I should spend any
for testing purposes i need an recursive directory with some files, that comes to
I want to transpose a matrix, its a very easy task but its not
Testing my app on some WM Std 6.1 I found out that it fails
I am trying to use webkit's support for CSS3 transform: matrix3d(<matrix>) to create a
I am testing a function containing nlfilter on a matrix. For the purpose I
How would you generate a random matrix that is not singular in MATLAB.? I
Testing: return request.getCookies() == null; is not an appropriate way test. Is there another
Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII

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.