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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:35:18+00:00 2026-05-31T20:35:18+00:00

I’m about to create a terrain for a mobile game which allows a huge

  • 0

I’m about to create a terrain for a mobile game which allows a huge terrain which is mostly limited by the available hardisk space.

This requires to keep the floating points limited to a "after-point-precision" of 2 numbers.
What is a good approach to keep it at the precision of 2 numbers after the point?

Remember: I’m running on a mobile device, so the method should be fast and easy to use and should be applicable to any arithmetic which is needed for games.

More information

I’m not talking about space( i know how much space a float takes guys, really ), i’m talking about the issue that i loose precision when my floating point is going to have to many numbers after the decimal point.

Using a int would cause that i’ve to convert the int into a float each frame. I don’t know how fast the conversion is but this seems to cost a lot of performance when doing it for a lot of objects. ( Remeber i’m on a mobile device ).

Of course i’m also not talking about the terrain, i’m talking about objects in the terrain! The terrain is a specialized system which actually can hold a terrain size which extends the limits of the floats a lot ( It’s even possible to save north america in this system when you have enough disk space, but actually the limits are set to -99km to +99km ).

Edit 2

As usual in games the movement is timebased, means i need to multiply the speed of the object with a modifier given to me by unity, this corrupts my numbers which are limited to 2 numbers after the decimal point.

  • 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-31T20:35:19+00:00Added an answer on May 31, 2026 at 8:35 pm

    An interesting way would be to implement this into the movement function:

    float result = //multiply force by time
    float modulus = result%0.01f;
    result -= modulus; //you will do this in any case
    if(modulus>=0.005f) {/*round up. if you want it to only round down, remove
      the next 2 lines, if you want it to only round up, remove
      the conditional statement*/
      result+=0.01f; }
    

    I can’t think about how to optimize it further, I removed the else statement and have it take away the modulus without condition as it will be done anyway.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I would like to run a str_replace or preg_replace which looks for certain words

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.