Raised This Month: $ Target: $400
 0% 

Convert int array to float array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Boonie
Member
Join Date: Aug 2015
Old 04-19-2017 , 14:28   Convert int array to float array
Reply With Quote #1

Is there a way to convert an into array to a float array.

This is the current way I am doing it:
Code:
size[0] = float(isize[0]);
size[1] = float(isize[1]);
size[2] = float(isize[2]);
Boonie is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-19-2017 , 15:17   Re: Convert int array to float array
Reply With Quote #2

No not really. you could make it easier on yourself and just loop through the elements.
Mitchell is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-19-2017 , 15:31   Re: Convert int array to float array
Reply With Quote #3

PHP Code:
for (int i 0sizeof(someFloatArray); i++) {
    
someFloatArray[i] = float(someIntArray[i]);

__________________

Last edited by ddhoward; 04-20-2017 at 02:36.
ddhoward is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-19-2017 , 18:06   Re: Convert int array to float array
Reply With Quote #4

Code:
sizeof(someFloatArray)
Seems a little performance heavy lol.
__________________
Neuro Toxin is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 04-19-2017 , 18:43   Re: Convert int array to float array
Reply With Quote #5

Why would sizeof be performance heavy?
__________________

Last edited by Impact123; 04-19-2017 at 18:56.
Impact123 is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-19-2017 , 19:36   Re: Convert int array to float array
Reply With Quote #6

Isn't sizeof evaluated at compile time?
__________________
Chaosxk is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-19-2017 , 19:37   Re: Convert int array to float array
Reply With Quote #7

Just a little thing ddhoward; you wrote:
Code:
int < sizeof(someFloatArray)
Quote:
Originally Posted by Neuro Toxin View Post
Code:
sizeof(someFloatArray)
Seems a little performance heavy lol.
sizeof is a evaluated at compile-time, it has no performance impact. But still unsure if that was sarcasm.


Why not create yourself a function to do it if you can't stand writing 3 lines each time? You know, code reusability, that's why they exist.

Last edited by klippy; 04-19-2017 at 19:37.
klippy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode