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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:40:41+00:00 2026-05-29T07:40:41+00:00

I am making a project that will use mathematic computations a lot. Also I

  • 0

I am making a project that will use mathematic computations a lot. Also I want to be able to simply change the implementation of real numbers. Let’s say between float, double, my own implementation and gmplib float types.

So far I thouht of two ways:

  1. I create a class “Number” which will interface with the rest of the program.

  2. I typedef the arithmetic type and write global functions to interface with the rest of the program.

The first choice seems to be more elegant, but the second seems to have less overhead. Is there a third better choice? Also I am worried by the elementary mathematical functions such as sine, cosine, exp… I figured out that to make the switching easy, I should implement them as templates, but my implementations are hopelessly slow.

I am generally new to programming in C++. I was brought up in the comfortable Matlab and Mathematica environments, where I did not have to worry about such things.

  • 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-29T07:40:42+00:00Added an answer on May 29, 2026 at 7:40 am

    Templates are the way I have done this. it makes it easy to specialize what must be specialized, and provides a good way to reuse implementations when it applies to multiple types.

    The number type can be done, but it’s actually not simple to do right and introduces some restrictions (compared to templates).

    Multiple types are just hopelessly complex, if you want something even close to fast, accurate, and simple to maintain. You’d likely end up using templates to implement these correctly if you were to create a global typedef.

    Templates provide all the power, control, and flexibility you would need, and they will be faster than the alternatives posted (technically, #2 could be as fast if you resorted to… templates).

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

Sidebar

Related Questions

I'm making a project that will scrap information about a movie and return all
I'm making a Windows Form project that will search for files in the specified
I am making a project that should compile on Windows and Linux. I have
I am making a Python gui project that needs to duplicate the look of
I am making a C# app for a class project. I want to ensure
I'm making pretty heavy use of reflection in my current project to greatly simplify
I have a sharp architecture project and I am making use of ApplicationServices in
I'm about to start work on a large project that will involve providing a
So I am making a complex project management system that is build completely in
I am tasked with making a custom ecommerce app that will populate purchase options

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.