Results 1 to 5 of 5
- 08-08-2010, 08:51 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 2
- Rep Power
- 0
FloatBuffer and 'put( float[] src )'
Hi All,
I am trying to use FloatBuffer created on top of ByteBuffer and having problems with using 'put ( float[] src )' method. 'put' for individual values seems to be working fine. Heres is the sample code:
Java Code:import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class TestFloatBuffer { private static final int COUNT = 3; private static FloatBuffer _fbb = null; /** * @param args */ public static void main(String[] args) { ByteBuffer tbb = ByteBuffer.allocateDirect( COUNT * 4 * 3); tbb.order(ByteOrder.nativeOrder()); _fbb = tbb.asFloatBuffer(); float[] src = { 0.0f, 1.0f,0.0f, 1.0f,-1.0f,0.0f, -1.0f-1.0f,0.0f }; _fbb.put( src ); _fbb.position(0); for( int i = 0; i < 9; ++i ) { System.out.println( "Index :" + i + ", val: " + _fbb.get(i) ); } } }
It does not print what is in 'src'.
I use:
$ java -showversion
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode
and
$ javac -version
javac 1.6.0_21
on Linux
I came across this bug report from a while back which looks similar, but it is reported as fix-delivered.
http://bugs.sun.com/bugdatabase/view...bug_id=6550579
Is this a known problem or have I got something wrong ?
Thanks
MaxLast edited by Fubarable; 08-08-2010 at 11:56 AM. Reason: Moderator edit: italics removed and code tags added
- 08-08-2010, 09:38 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
I ran your code on Java 1.6.0_20-b02 and it ran fine; b.t.w. you're missing a comma in the third line of your array initialization.
kind regards,
Jos
- 08-08-2010, 10:02 AM #3
Member
- Join Date
- Aug 2010
- Posts
- 2
- Rep Power
- 0
How embarrasing
Thanks Jos,
that was that coma, should not have posted this :-P :-)
thanks again
Max
- 08-08-2010, 10:06 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
-
Moderator edit: italics tags removed and code tags added to aid readability. To learn to do this yourself, please check out the links in my signature.
Much luck and welcome!
Similar Threads
-
string to float
By Sungron in forum New To JavaReplies: 3Last Post: 02-02-2010, 09:23 AM -
Working with float
By dardar in forum New To JavaReplies: 8Last Post: 01-27-2010, 08:29 PM -
java java.nio.FloatBuffer
By sardare in forum Advanced JavaReplies: 2Last Post: 04-24-2009, 10:33 PM -
Float vs. Double
By javanub in forum New To JavaReplies: 1Last Post: 11-23-2008, 12:11 PM -
Class float
By Peter in forum New To JavaReplies: 1Last Post: 07-08-2007, 01:17 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks