AkelisRain
Member
Am I allowed to ask for Java help in here? I don't see a dedicated thread for Java. :/
Am I allowed to ask for Java help in here? I don't see a dedicated thread for Java. :/
All languages are allowed here! This is the catchall and there are several Java programmers that post in it.
radius = Math.pow(3*volume/4*Math.PI, 1/3);
Two things wrong with this line.
Code:radius = Math.pow(3*volume/4*Math.PI, 1/3);
First, 1/3 is evaluated using integer math. The result of 1/3 is 0 and some number to the power of 0 is 1.
Second, know your order of operations, as Rush_Khan mentioned.
Thanks, didn't even think to look over my Order of operations.I've never used Java and I may be wrong in this, but I'm guessing you need brackets to contain the (4*Math.PI), otherwise you're dividing by 4 and then multiplying the whole thing by pi.
One other thing, I wouldn't make surfaceArea and radius as instance variables, unless this was specified by your professor.
The Tiobe index?Hey everyone. Does anyone have a good source with the popularity of programming languages over the years? I plan to use that info for a presentation I'm supposed to give soon. Doesn't have to be fully accurate (which would be impossible).
The Tiobe index?
In a single cycle data path, there is a critical path. That is, the "longest" route in time will determine how long the enter path must take.
In a multicycle data path, everything is broken into stages. The longest stage determines how long each stage will have to be.
In a pipelined data path, it's the same as multicycle. In the PLDP, you can't skip stages (ie a J instr takes 3 stages in MCDP in comparison to PLDP), each instr must go through each stage in the pipeline. This is to keep everything synchronized in the pipeline.
So, you look at the how many cycles each TYPE of instr takes, and their percentage in an instr set. From there, you can calculate the average CPI, or cycles per instruction. (Cycles/Instr)
Clock rate is how many cycles can be done per second (Cycles/Second). The fast the clock rate, the more Cycles can be done per second, which means it will get through those instructions faster, as instructions are made up of multiple cycles.
Clock time is the amount of time it will take a processor to complete a set of instructions. This is just in seconds. It's the Clock Cycle Time * CPU Clock Cycles, or CPU Clock Cycles / Clock Rate (which makes sense, because it's the total number of clock cycles it needs to do, divided by how many it can do in a second).
Using these tools and the information given in problems, and doing a lot of unit matching, you should be able to solve practice problems easily.
Not sure about latency, I'm assuming you just compare the performance between two machines and that should be enough. You can do that just by comparing them as ratios.
Hope this helps, I have my final on it tomorrow too. Good luck dude!
So, for my senior project in the fall I plan on porting the board game telestrations over to a mobile platform. Probably Java/Android since I've been having trouble setting up a Mac VM on my pc. The only problem with this is my mobile devices are ios so live testing will be cumbersome for me lol. I've also never written a mobile app so I'm relying on past Java/C++ experience to pull me through.
Also, I want to incorporate network play via Internet so I think I need an application server, but I've never set one up before. Anyone know what I should look at to get started on this? I do have web server hosting already so I have access to a MySQL database and I've written web apps before, is this much different? (I.e. Establish a db connection and then use built in functions to interact with the db through the connection resource)
In C#, if modulo is computationally expensive, what's an alternative to determine if an int is even or odd?
It's a language that compiles to native code, is close in speed to C/C++, is much safer due to a powerful type system (without using a GC) and a lot of modern language features. Here is the official site.Is there a TLDR version of why Rust is so good for someone that hasn't followed it at all?
I don't think I've ever encountered a situation where a modulo operation was the bottleneck, but you can check the last bit to see if the number is even or odd. You'd definitely have to benchmark that, also.In C#, if modulo is computationally expensive, what's an alternative to determine if an int is even or odd?
In C#, if modulo is computationally expensive, what's an alternative to determine if an int is even or odd?
You'd really need to respect endianness there though, so that'll introduce more ops, which will make it lose.rhfb said:I was wondering so I benchmarked it.
100 million random ints, modulo and bit checking.
bit checking took 1.4 seconds, modulo took 1.5 seconds.
Thanks for the recommendation. This will be a good way for me to learn c# too, though from what I've seen of code snippets it never looked very different from Java.You could look into Xamarin. Free for students and you get an app that runs on iOS, Android, and Windows. You can build the app in visual studio. No mac necessary. http://xamarin.com/student
Thanks for the recommendation. This will be a good way for me to learn c# too, though from what I've seen of code snippets it never looked very different from Java.
It's a language that compiles to native code, is close in speed to C/C++, is much safer due to a powerful type system (without using a GC) and a lot of modern language features. Here is the official site.
It took 100 million ops to gain .1 seconds. I'd say it doesn't matter lol.I was wondering so I benchmarked it.
100 million random ints, modulo and bit checking.
bit checking took 1.4 seconds, modulo took 1.5 seconds.
I was wondering so I benchmarked it.
100 million random ints, modulo and bit checking.
bit checking took 1.4 seconds, modulo took 1.5 seconds.
It's reasonable to assume that modulo is the fastest way to find out if an integer is even or odd. All other variants I can come up with need multiplication / division, multiple comparisons, the ampersand operator, multiple bitshifts, ...
Even Math.DivRem will lose because it respects the quotient.
I suppose (x & 1) == 0 will come close, but there's an extra comparison there, so it'll probably lose.
I would strongly advise using modulo.
You'd really need to respect endianness there though, so that'll introduce more ops, which will make it lose.
Still haven't found a solution to the problem I posted about on the last page.
I think I should describe it at a higher level:
It's a Java EE application. There are three classes involved with the part I'm working on right now: A Message-Driven Bean called Server, and two clients called Scheduler and Client. They communicate asynchronously using JMS queues. Here's the message flow:
- The scheduler sends a message with some data to the server
- Based on that data, the server creates a new entity, sets some fields, and persists it
- The server creates a DTO from the previously persisted entity and sends it to the client
- The client processes the data and sends the modified DTO back to the server
- Using the ID from the received DTO, the server reads the corresponding entity from the database and updates it with the other fields from the DTO
The server is using a PersistenceContext powered by Hibernate and an embedded H2 database. So I'm persisting and reading using em.find(myEntity) and em.read(MyEntity.class, dto.getID()).
The first four steps work perfectly, but I have problems reading the entities from the DB. When I use the EntityManagers find() method with the ID, it doesn't find anything and just returns null. Yet, when I create a query that's just "from MyEntity where id=:id", it works. And after executing that query, the find() method suddenly returns the entity too.
This sounds like 1) the persist operation is not immediately committed and 2) reading from the table kinda triggers the commit. But why only if I use a query, and not if I use find()? I've printed the generated SQL, it's exactly the same for find() and createQuery().
However, sometimes (rarely), even createQuery doesn't find the entity. So using it as a workaround is no option.
I don't know what I'm missing here, but it has to be something regarding synchronization and/or transactions.
Haha that's great.
Haha that's great.
Man, this internship is great, but my time there has revolved around learning their tools. Feels like we should have had a version control/build bot class in school because I've known none of the stuff they've thrown at me.
A thousand times yes. And debugging too with actual debuggers.
Did you try out CLion? I tried that after getting annoyed with Xcode, and with booting Windows every time, ended up trying CLion out and it's been nice.Spent some time today working with C++ in Xcode. And it's such a pain in the ass, I'm this close to just installing Windows on my laptop to get Visual Studio.
Gonna try to force myself to use it some more over the weekend. Maybe I will somehow end up getting used to it.
Is there more to debugging than reading the compiler errors and stepping in/out/over through your program run? Because that's how I debug my stuff. That and writing output at certain steps to fix logic errors. I find compiler error readings to be the most helpful and it baffles me that so many students don't understand them.Grr, don't even get me started. It angers me they don't teach basic debugging skills in school. It's so easy to do and will increase your grades a ton
While it's basically what you described, learning the debugger's commands and using them effectively is seriously helping me. Learning how to do something as simple as jumping between threads, inspecting data at different frames, and putting a watch point on variables really ups their value.Is there more to debugging than reading the compiler errors and stepping in/out/over through your program run? Because that's how I debug my stuff. That and writing output at certain steps to fix logic errors. I find compiler error readings to be the most helpful and it baffles me that so many students don't understand them.
Is there more to debugging than reading the compiler errors and stepping in/out/over through your program run? Because that's how I debug my stuff. That and writing output at certain steps to fix logic errors. I find compiler error readings to be the most helpful and it baffles me that so many students don't understand them.
You'd be scared to know how many students get by through classes without even that much knowledge of debugging.
Just tried it this morning. Had to mess around a bit with CMake to get it to work with SDL2. I'm a bit unsure how the building process works, but at least for now I got it running after looking up some sample build steps online.Did you try out CLion? I tried that after getting annoyed with Xcode, and with booting Windows every time, ended up trying CLion out and it's been nice.
I only use it for C though so I don't know how good it is for C++, also needs a student license
Is there more to debugging than reading the compiler errors and stepping in/out/over through your program run? Because that's how I debug my stuff. That and writing output at certain steps to fix logic errors. I find compiler error readings to be the most helpful and it baffles me that so many students don't understand them.
Hello programmers!
First time here, what's up?
I've been digging some Go lately, using Vim primarily for good 5-6 months.
Just tried it this morning. Had to mess around a bit with CMake to get it to work with SDL2. I'm a bit unsure how the building process works, but at least for now I got it running after looking up some sample build steps online.
Will probably stick with it for now.