[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


fast conversion int<->float<->double arays

Posted on 2004-11-09
Medium Priority
Last Modified: 2008-02-01
I am looking for fast conversion routines that convert between arrays of int (different types|widths), float, and double.
They should use platform-specific instructions (e.g. SIMD2) if available, or fall back a portable solution otherwise.

I am *not* looking for loose links/snippets how to do individual conversions.

Any suggestions?
Question by:peterchen092700
  • 4
LVL 22

Accepted Solution

grg99 earned 80 total points
ID: 12543362
You may not like this suggestion:

You're probably barking up the wrong tree.  Converting the data is very unlikely to be a bottleneck:

(1)  Assuming the data came off or is going to the disk or network, the I/O has to be much slower than the conversion time.

(2)  If the floats are going in or out of some computation, any non-trivial computation is going to be much slower than the conversion.

(3)  If you really want to speed up the code, recast it so no data conversion is required.

So I suggest you look elsewhere for speedups unless you can show that the conversion really is a speed problem.


Author Comment

ID: 12546056
Problem is, this goes into a tool library that runs background services which should have lowest possible impact. If I find something ready made that reduces time by 5%, I'm fine. (If I have to code two days, it's not worth the trouble)

The data conversions are unavoidable, since they are interfacing different components.

(I think the biggest time easter will be running through the 128K*8Bytes of memory anyway)

Author Comment

ID: 12747069
Can be closed for my part.

Author Comment

ID: 12748878
umm... I can't close it with points refunded, right?
(haven't been here often lately...)

while grg99's comments are valid, they don't answer the question at all.

Author Comment

ID: 12749889
I've obviously not been here for too long... sorry.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question