playMaker

Author Topic: Get Float Right  (Read 1476 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Get Float Right
« on: November 13, 2018, 01:48:38 PM »
Hello. I need an action that gets the rightmost two places of a float variable. currently I have to convert the float to a string, get string right 2, then convert that to a float again.

so if the input float is 632, the result of this action would be 32.

also it would be great to have a similar one for get float left. thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Float Right
« Reply #1 on: November 14, 2018, 01:10:47 AM »
Hi,

 https://stackoverflow.com/questions/701322/how-can-you-get-the-first-digit-in-an-int-c

So yes getting the string is the slowest, but if you are not using this every frame during your game loop, you'll be fine.

 what is this number in your game and how often do you want to perform this check? maybe there is a way to get to the source of the generation of this number and get the data there instead of after?

Bye,

 Jean