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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:37:37+00:00 2026-05-23T03:37:37+00:00

I am making a toy physics engine which works with floating point numbers which

  • 0

I am making a toy physics engine which works with floating point numbers which I call reals.

At present, I am using a typedef;

typedef float real;

This is so I can change the precision of the floating point values to doubles or long doubles, but obviously I have to recompile. I would like to be able to cleanly define the type of real at runtime, so that I can specify the precision via command-line or an intialization GUI interface.

I know typedef is determined at compile time, so I am wondering if anyone has any neat ideas.

  • 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-23T03:37:38+00:00Added an answer on May 23, 2026 at 3:37 am

    A float uses less memory than a double and is less precise.

    BUT, there is only one set of math libraries and it is double based. All floats get converted to double for calculations and then must be cast back to float.

    Just use doubles.

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

Sidebar

Related Questions

Making a game using Blender for 3D models and Unity for the game engine.
I have been making a little toy web application in C# along the lines
Making an adobe flex ui in which data that is calculated must use proprietary
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
Making a small WCF test program which is based on a Store that has
Making a request to a RESTful service in Silverlight with HttpWebRequest works well so
Making a simple program which will generate a multiple choice form. I have an
making a call to a web service method with nusoap returns an error array(3)
I am making a tile game. Was following http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d . Using the whole screen
making a thumbnail from video using the picker is straight forward. However, when I

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.