| |
| |
| |
|
Page: 1 2 3
Comments:
<0> kosder please see topic, no pvt msg <1> done... <2> Why do they pick on you, calchas? <1> cause his got an interesting nick... <2> A famous soothsayer in the Trojan War, I see. <1> ;) <1> you appreciate these things more if you are greek ;) (out of topic...sorry, no ore comments) <2> malaka <0> it's still a greek male name isn't it? <3> Hi. I'm trying to do a function to solve equations using bisection method. At one point, I'm comparing a == m or || b == m ([a,b] and m =midpoint) . but i'm only concern with a specific precision ,let's say 0.001 . I'm using double as my variables. how can I compare truncating the rest of the digits that I don't care about. I look at the java.lang.Math , but the round does not do that. <2> Francisco_: Do you mean you want to format your output? <3> not the output. I know how to format the output <2> Francisco_: You want to round intermediate calculations to 3 decimal places? <3> because I'm looping to find the roots <3> I want it to save time on the loop by rounding to a precision like 0.001 precision . <2> Francisco_: You want to round intermediate calculations to 3 decimal places?
<3> saying that 1.0110202 = 1.01103333 <2> Hello? <3> yes, I want to round up <2> In intermediate calculations <3> to decimal places, say 3 <3> in here <3> if (a == m) <-.... <2> Why not just ask if the difference between two numbers is less than an amount? <1> good point... <3> i'm using the bisection method, this method, has two intervals a and b <2> I think it's gone read-only. <3> and m = (a+b)/2 which is the midpoint <3> is it possible to do what I asked? <3> in termes of truncating the decimal places <1> you could make a string from the double and then create a substring...but its waste of time... <3> to 3 for example <2> Francisco_: You seem to be ignoring suggestions. <4> Francisco_ http://www.****inson.edu/~braught/courses/cs132s01/cl***es/code/Rounding.src.html <4> this source implements a function Round to x decimal spaces <2> BlueLeaf: That is so ****. <3> thanks BlueLeaf <2> It doesn't work. <0> do not truncate intermediat variables stop when the a to b interval is less than your stated precision <0> rounding numerically is wrong <5> good night <3> calchas, so you say that when a or b is less that precision... Ok I see that <0> nod <0> it's the same effect, and doesn't introduce any unnecessary errors <3> yet, I wasn't thinking truncating while calculating, only during the comparasion, by the way <2> Rounding numerically with floating point arithmetic is flawed, because floating point arithmetic can't represent all numbers accurately. <3> calchas, I see your point <0> that is still adding in error <6> Hi <0> for display purposes (to remove the binary quantization, use Decimalformat <2> System.out.println(1.0f/10-0.1); <6> anybody here write games in java? <2> urz: If there's a question, ask it. <6> I im just trying to get into it, and i made some bouncing ball animation <6> But my problem is the game loop <1> using sprites? <2> Games don't need loops. <2> Try event-based programming. <6> i dont want to <6> do i have to? <6> I dont think i have a timer with good enough resolution <7> what does time have to do with resolution? <6> the resolution of the timer is how often it fires <2> Or how accurately it measures the fire frequency. <6> ya <6> well i come from c++ game coding <6> and there, i prefer to make a game loop <2> You don't want your 'game loop' to be on the event dispatch thread, if you're using AWT/Swing. <6> well i am using swing <6> I put the loop in main() but the actual rendering happens on paint() <2> paint() is for AWT, not Swing. <6> ok <2> Do you call paint() yourself? <0> app logic should not be in main <0> need to learn some OO <6> well really, i want your opinions on what i should be doing/using <6> for games
<2> urz: http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html is worth understanding. <8> Ah, you can sneak a little repaint() in there :D <0> Object oriented design for a start <2> teralaser: Yes, repaint is threadsafe. <6> i know OO <4> yes, an Objects-first approach <2> urz: Most Swing apps will tend to only do an invokeLater from main. <6> yes, i do that <2> urz: Only. <6> well im not sure, i wrote the code a few days ago <2> And now it's encrypted? <6> well hold on <3> calchas, thanks. I did it. it worked. <6> its not very large, i'd like to post the whole file <6> what do we use for code pasting here? <6> in main() i have only an invoke later <9> Topic? <6> but i create a new thread from in the run() command <2> Right, so your game loop isn't on main after all. <6> right <6> its in that thread <2> I haven't tried this out yet, but the way I'd do it is to have an offscreen image, and have the separate thread update that, and from the EDT draw that image onto a component (new JLabel(imageIcon) will do that). <6> in that thread, i use a loop and a Thread.sleep() in order to try to ensure a specific frame rate <2> And do you call paint directly? <6> i call repaint() directly <2> Then the component will get repainted when the image is changed. <6> you are saying i should call paint() instead of repaint() ? <2> No! <2> What you've got doesn't sound too bad. <6> hm <10> wb Bryin <8> http://www.bash.org/?605501 <2> teralaser: 42. <8> That's two digits ! <2> 4 if you're drunbk. <8> didnt you recently brake up with someone, ricky_clarks : http://www.bash.org/?602698 <8> :D <8> break even <2> Yes, but I dumped her. <11> hey how can i return 2 variables in a metod? <12> make a new cl*** and return that, or return an array, or a map, or... <13> VaTo: normally that means you have a method that's trying to do two things at once, that's not very often a good idea at all. <14> http://pastebin.com/518349 anyone know whats wrong with that? im trying to get the char array newsrch to be the reverse of the srch array <14> instead of the reverse of srch, it stores a bunch of garbage <8> ryann : j >= 0 <8> not what you wrote <14> out of bounds <8> :D <14> j >= 0 gives out of bounds error <8> oh, you need j = srch.length; <8> bah! <8> j = srch.length - 1; <11> well i would like to return an array in a metod <11> how can i do it? <15> return yourarray; <11> return prueba[]; and retu <11> is wrong <8> last valid index is srch.length - 1, not srch.length , a java/c curiosity <8> ryann <11> if i put return myarray; it tell me incompatible types <14> hmm, it returns the reverse, but still gives out of bounds <14> oh, wait, thats another part of the program <8> Man, one bug a line ! <15> It's easier to use a for loop. <8> nah easiest thing must be new StringBuffer("halB halB".toCharArray().toString).reverse().toString.toCharArray(); <8> Poor professor, I ruined all his standard learn-a-loop homework stuff by giving that line out :D <2> teralaser: new StringBuilder("halB halB").reverse().toString(); <8> ah, those 1.5-inventions <2> Builder/Buffer, doesn't matter. <15> ricky_clarks: he seemed to need char[] not String (one more step) <2> I know, but I ignored that because I doubt he really needs char[]. ;)
Return to
#java or Go to some related
logs:
#MissKitten #AllNiteCafe #linux #linux gsl esp properly saved #linux #linux #javascript #MissKitten #php
|
|