473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

STL map impl. in C

Hi--

Is it possible to index an array using floating point numbers
instead of integers (0 through n)? I have an array M in which
one of the indices is a floating point number. Previously, I used
a dirty work around for conversion of this index into an int
(I found out that this is causing a loss in accuracy).

map<> template in STL can be used to index arrays using strings,
floats etc. Is there any implementation of map<> in C?
Any help would be very helpful to me.

Thanks in advance..

-- S Muddu
Nov 13 '05 #1
2 3521
Swamy Muddu wrote:
Hi--

Is it possible to index an array using floating point numbers
instead of integers (0 through n)? I have an array M in which
one of the indices is a floating point number. Previously, I used
a dirty work around for conversion of this index into an int
(I found out that this is causing a loss in accuracy).

map<> template in STL can be used to index arrays using strings,
floats etc. Is there any implementation of map<> in C?
Any help would be very helpful to me.

Thanks in advance..

-- S Muddu

Perhaps you should write more explicitly what you want:
array[(int)(x)]
array[lrint(x)]
array](int)ceil(x)]
.....
Compilers tend to be lacking in ESP, as am I. Google searching doesn't
enlighten me on any relationship STL map<> might have to C or your
question. Nor am I enlightened as to how you might cast float or double to
int without loss of accuracy.
--
Tim Prince
Nov 13 '05 #2
"Swamy Muddu" <sm*****@hotmail.com> wrote:
Hi--

Is it possible to index an array using floating point numbers
instead of integers (0 through n)?
IIRC arrays can't be indexed by non-integral expressions (char, int, enum).

You could keep the number in a float and use a rounding function when you
want to index the array.

I have an array M in which one of the indices is a floating point number. Previously, I used
a dirty work around for conversion of this index into an int
(I found out that this is causing a loss in accuracy).

map<> template in STL can be used to index arrays using strings,
floats etc. Is there any implementation of map<> in C?
Any help would be very helpful to me.

Thanks in advance..

-- S Muddu


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Kanter | last post by:
Hello, I have a question regarding SendKeys(). I am working on a small VB .Net script that manipulates/automates programs through SendKeys(). Unfortunately, I have run into several problems. ...
1
by: Timo Qvist | last post by:
Hi, I'm a bit new to STL and really new to SGI's hash_set implementation and I've having problem instantiating a hash_set with a custom hash function, I could really use some help sifting through...
0
by: daechulsohn | last post by:
Just thought I would contribute some knowledge for a change. After hours tracking down a problem with obfuscated code, where we were getting the exception : System.TypeLoadException: Method a...
1
by: MariusI | last post by:
I have some business objects which overrides Equals to provide syntax equality instead of just reference equality. Overriding equals gives me a warning that i must override GetHashcode(). Msdn says...
1
by: soyspinoza | last post by:
hello out there, does anyone know of a good C/C++ implementation of the hungarian algorithm, (i.e. munkres algo?) thanks,
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
12
oll3i
by: oll3i | last post by:
when i launch the application from sun application server the console opens throws something i cannt even read what and closes before the application opened and threw nullpointerexception now it...
2
by: Chris Thomasson | last post by:
I was wondering if the 'SLINK_*' and 'SLIST_*' macros, which implement a simple singly-linked list, will produce _any_ possible undefined behavior: ____________________________ #include...
1
by: anon | last post by:
Chris Thomasson wrote: Not related to threads, but it might happen, depends how is it implemented: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.