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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:27:30+00:00 2026-05-18T08:27:30+00:00

Sometimes I have to convert from an unsigned integer value to a float. For

  • 0

Sometimes I have to convert from an unsigned integer value to a float. For example, my graphics engine takes in a SetScale(float x, float y, float z) with floats and I have an object that has a certain size as an unsigned int. I want to convert the unsigned int to a float to properly scale an entity (the example is very specific but I hope you get the point).

Now, what I usually do is:

unsigned int size = 5;
float scale = float(size);
My3DObject->SetScale(scale , scale , scale);

Is this good practice at all, under certain assumptions (see Notes)? Is there a better way than to litter the code with float()?

Notes: I cannot touch the graphics API. I have to use the SetScale() function which takes in floats. Moreover, I also cannot touch the size, it has to be an unsigned int. I am sure there are plenty of other examples with the same ‘problem’. The above can be applied to any conversion that needs to be done and you as a programmer have little choice in the matter.

  • 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-18T08:27:31+00:00Added an answer on May 18, 2026 at 8:27 am

    There is an implicit conversion from unsigned int to float, so the cast is strictly unnecessary.

    If your compiler issues a warning, then there isn’t really anything wrong with using a cast to silence the warning. Just be aware that if size is very large it may not be representable exactly by a float.

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

Sidebar

Related Questions

I leveraging the XmlSerializer to convert to/from XML. Here is an example class: [XmlRootAttribute(myClass)]
I have a large table of birthdays that I want to convert from a
For my work, I sometimes have to deal with logfiles from a binary protocol
I sometimes have difficulties with other people who wish to solve a problem when
I sometimes have issues with the incremental rebuild on visual C++ (2003 currently ).
In our application we sometimes have to make minor GUI modifications for different customers:
In my database application I sometimes have to deal with null strings in the
My situation: I have several components, which sometimes have changes to them, and are
In the Visual Studio code editor, I sometimes have an extraneous mark on the
Sometimes I have to work on code that moves the computer clock forward. In

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.