Everything posted by Sensei
-
Where do algorithms go in the java program heiarchy
That is correct. Object and class are building blocks in Java language. Program written in C/C++ is compiled to machine code. Understood by some physical processor. It runs directly only on CPUs which understand it. Program written in Java is compiled to special code. It is executed on virtual machine. Simulation of the real computer. This disallow program direct access to mother machine devices and resources. e.g. if you allocate memory in Java it is from JVM heap. It is problematic on Android for example. Default heap size on my smartphone is.. 128 MB per app. Programmer has to set special field in manifest largeheap=true to get 512 MB. Virtual machine interprets Java special code to the real processor instructions.
-
Programming Book Recommendations
This is good for a beginner: https://www.w3schools.com
-
Where do algorithms go in the java program heiarchy
Read about spatial database: https://en.m.wikipedia.org/wiki/Spatial_database e.g. Google maps, computer game playfield, stars and galaxy database etc. It is an example of data which dictates the most optimal algorithms to store and query records. Sorry. That part was meant to be together with the rest of my reply but was split to two by Prometheus's post written in the middle of my longer reply.
-
Where do algorithms go in the java program heiarchy
There is no sense to use Kd-tree or octree algorithms on data which are not 3 dimensional. There is no sense to use quad tree on data which is no 2 dimensional. So the number of dimensions of data forces programmer to use or not use specific algorithms. OP said: Therefore I replied, "blackbox is not an algorithm".. No teacher would say "let's apply the blackbox algorithm".. Blackbox is lack of knowledge about specific implementation by unauthorised people. e.g. programmer executing method Collections.sort( list ); has no idea whether it is quicksort algorithm or bubble sort algorithm. Authors of this method/class know what is algorithm used there in the reality. 3rd party programmers don't. Unauthorised programmer can gain knowledge about specific implementation by reverse engineering the code.
-
Where do algorithms go in the java program heiarchy
Blackbox means that you have no idea how 3rd party library or class is working internally and it can be changed at any time by the creator e.g. your app connects to database. It could be MySQL, SQLite, in-memory db, or something less recognizable.. Blackbox is not an algorithm. Usage of certain algorithms sometimes force programmer to use of specific solutions e.g. hash map requires that class will calculate hash code for supplied data. Lack of proper implementation of hash code method e.g. return 0 all the time, will lead to useless non optimal hash map which will work slower than plain list/array. If you are expecting there will be very few elements in the collection there is no sense to use hash map. It will just slowdown. The amount of elements in collection dictates you what algorithm you should use to have the quickest and the most optimal access to a single element. e.g. list/array of strings (specific data source) "begs" for being sorted alphabetically and then usage of binary search algorithm to find exact element (string) on the list. Binary search algorithm will find element in O(log2(x)) instead of O(x). Make graph f(x) of both functions to see how much can you gain depending on value of x.
-
Updated to latest forum software
@Dave if you will compare computer version of the forum with mobile version of reply UI panel, you should see there are missing buttons e.g. subscript and superscript icons in mobile. Is it fixable?
-
Binary to Data Types
Don't try to understand, just use them.. You don't understand how computer works but still use it either. Understanding how something works grow together with the amount of stuff that you wrote (programmed). It is not heart surgery. Don't have to know how it works internally with great details. Bugs and problems are unavoidable and common day stuff for any programmer. The best programming tutorials for beginners IMHO are the one which explain "How to write app xxx". Because they are not boring. You immediately see effects. You repeat what tutor is presenting and together with him or her repeat line by line. Attempt to explain everything will lead to uberboring textbook. To store name you need e.g. string. In C++ you write: std::string first_name; Then you need to have surname: std::string surname; Then you need age. Age is integer with years. int age; put them in separate class together: class Person { std::string first_name; std::string surname; int age; } You need to create object of this class so you use: Person *person = new Person(); and you need to initialize it: person->first_name="John"; person->surname="Doe"; person->age=34; Abstract/custom data type. For app which stores people data. You don't need to know how std::string was implemented. And you will never know it. It is blackbox. You can only know what methods and fields were exposed to public and read about their parameters and properties in the reference.
-
Binary to Data Types
FPU stands for Floating point unit. https://en.m.wikipedia.org/wiki/Floating-point_unit ALU stands for Arithmetic logic unit. https://en.m.wikipedia.org/wiki/Arithmetic_logic_unit If CPU has no builtin instructions which operate natively on the datatype, they need to simulate it in normal code. Such virtual datatypes are created in every C++ or Java project. Programmer-scientist usually needs to have limitless resolution of the number so needs to make (or find library with ready solution) which will allow much better precision than 64 bit integer to 64 bit double. CPU which has no FPU built-in nor external FPU had to simulate IEEE 754 in regular code. If you would like to have 128 bits or 256 bits floating point number you would have to make such code by yourself. It is kinda fun task.
-
Binary to Data Types
They have meaning. Integers are understood by ALU. Floats and doubles are understood by FPU. These days FPU is builtin CPU. But in '80 and early '90 in 386 and early 486 FPUs were external chipsets. Coprocessor. Floats are in IEEE 754 standard. https://en.m.wikipedia.org/wiki/IEEE_754 It is much harder to convert float or double to human readable format than plain integer. Therefore there is plentiful parameters which you need to bother about during conversion. Read printf/sprints C/C++ manual %f and %g.
-
Binary to Data Types
Bit can contains value 0 or 1. If we group 8 bits it is byte. The all other data types have resolution in multiple of byte: 16 bits, 32 bits, 64 bits etc. From computer point of view they are always binary. If typical computer application must print number to user, it has to convert binary to decimal (for non-programmers). It is just on screen. Internally it is is still binary. Conversion takes CPU time and memory. In older times sometimes was used BCD. Now I think it is obsolete. https://en.m.wikipedia.org/wiki/Binary-coded_decimal It could be found in e.g. embedded systems. Display and basic maths are easier and takes less time than full binary to decimal conversion (because they need multiplication, division and/or modulo.. which maybe are not implemented in cheaper weaker chips e.g. Atari/C-64 CPU Motorola 6502/6510 don't have built-in multiplication, division and modulo instructions). CPU has flags: zero, overflow, carry, nagative and others. Some CPU instructions modify some of these flags. Usually arithmetic instructions. If you subtract e.g. variable x0 from x1 (register from register/memory) and you get zero result there is set zero flag in CPU. What does it mean? That x0 was equal to x1. Therefore instructions to perform jumps are called je, jne, beq and bne. Shortcuts from Jump if Equal. Jump if Not Equal. Branch if EQual and Branch if Not Equal. They test state of zero flag in CPU. It is what is used by higher level languages if()/for()/while() etc. functions. And by Boolean to check its state and perform jump. What you see on the screen is just bunch of pixels with shape of digit.
-
Subtext cipher?
I got "nunca mais" which means "never again"..
-
Charging Africa
Inverse square law is e.g. [math]P = \frac{P_0}{4 × \pi × r^2}[/math] From total power of the Sun P0 we get P in W/m^2. And it (P) is what we can measure using physical devices. To get total power of the Sun (P0) we have to reverse inverse square law equation to: [math]P_0 = P × 4 × \pi × r^2[/math] This is also used to measure distance to stars. Earth due to orbiting the Sun is 300 mln km nearer to the star and half year later it is 300 mln km farther from it. Brightness of the star periodically changes due to increased or decreased distance, so we can deduce r (distance).
-
Charging Africa
It the opening post Danilo said "Once, I heard about that the Sun releases 1,7x10^17 J per year".. but gave incorrect value. 3.846×10^26 W is calculated from ~1370 W/m^2 × (~150×10^9 m)^2 × 4 × 3.14159265. It is value that you gave earlier in this thread too. But you didn't multiply by the number of seconds per year to match OP units "J per year". What energy Sun releases per second, or per year, is one thing. What arrives to the Earth is another thing. It gets tricky to calculate what really reaches Earth surface as you have to take into account latitude, longitude, altitude, weather, reflectivity of surface (e.g. white snow reflects light) etc. etc. What is the origin of Danilo's data i.e. 1.7 × 10^17 J.. ? 1370 W/m^2 × 3.14159265 × (6,370,000m)^2 = ~ 1.75 × 10^17 W.. So it is energy per second (without taking into account angle), not per year as Danilo wrote. At noon, and in the best weather possible conditions.
-
Charging Africa
Correction: it must be multiplied by 4 PI. ~1370 W/m^2 × (~150×10^9 m)^2 × 4 × 3.14159265 × 60s × 60 × 24 × 365.25 = ~1.222 × 10^34 J per year. ..and they could work online, and be paid by western country companies, work as e.g. software engineers. Therefore they also need fast reliable Internet connection with the rest of world. This way they won't have to abandoned homes and searching for a better life in the Europe risking losing life in travel.
-
Charging Africa
OP said "per year".. We should calculate the energy which truly arrives to the Earth's surface. With inclusion of day-night variations. With analysis of angle (majority of the land is in the Northern Hemisphere)
-
Charging Africa
That's certainly not correct value.. Earth gets ~ 1370 W/m^2 (in atmosphere). And is ~ 150 mln km away from the Sun. ~1370 W/m^2 × (~150×10^9 m)^2 × 60s × 60 × 24 × 365.25 = ~9.728 × 10^32 J
-
Dark energy
I need his source code..
-
Google vs Nation States
They should not short sell in the first place! It is not constructive financial tool (in the case of stock market, in commodity exchanges it is completely different story). Doesn't build, but ruins businesses. If somebody thinks company is a bad business or eventually it will collapse should not buy their stocks. But if you short sale their stocks, that is evil! You are causing collapse of the company in shorter time. Hedge fund managers got what they deserved for and they were punished..
-
Google vs Nation States
I think market always behaved this way, but behind closed doors e.g. couple powerful investors making secret agreement and causing up rise or fall down of the company stock's together without everybody knowing about it. Now crowd of ordinary people can do it completely openly on the Internet. Before XX century there were bankruptcy of banks caused by spreading of rumours about sudden insolvency. Some were completely true, some others were lies. Attempts to regulate this will lead to permanent censorship of literally everything. e.g. people won't be even able to complain about malfunction of the product which company sales, even if their complains will be absolutely true (and which will lead to eventual fall of stock price of the company). "Talk about company (and their products) always in positive light or don't talk at all".. That is what you want? Who will judge they said lies about the product? Who will judge that rumours about company insolvency is true or lie? Court? No. Because the all details of how good or bad is situation inside the company is under control of the company and they can show court whatever lies they want.. What rating had companies and banks in 2008, a day before financial crisis? The highest possible! People proclaiming collapse of the system were mocked, censored, marginalised, sued. If somebody would publicly complain on CDS before 2008, banks which made millions and billions selling them, would sue person, because he or she attacked branch of which they are sitting and making profit on it.. If they would have a tool which you want them to introduce by making regulations, they would use it straight away to shut up mouth of wistleblowers..
-
A Simple Arithmetic Teaser !
Some irrational numbers e.g. PI have infinite number of digits of each kind in decimal numerical system.
-
extracting text
PDF contains text and images. Start from making sure your text is really text, not image. e.g. some people scan paper documents and output from scanner (images) are put as is inside of the PDF document. To handle images there is needed OCR. Completely different procedure. Also text can be in several columns. Attempt to OCR will result in having couple words from each column mixed each row! Find some example here and copy and paste it for a start: https://www.google.com/search?q=python+extract+text+from+pdf This is what ordinary layman would do. Programmers write scripts which will automatically extract needed data. Manual extraction of data from thousands files would take months or years of work. In some not computerised countries and companies, people still work that way in offices. That's bizarre. And results in waste of human resources, ineffectiveness, inproductivity of company, office or government. Inability to compete with the real world were such job is done by programmers. Programmers wanting to extract data from documents have different than amount of information, problems like damage of character encodings (it doesn't bother much UK, US, Australia and Canada programmers, but the rest of world indeed), text in scanned images, text in columns, incorrect recognition of the letter by OCR etc. etc.
-
can we travel to mars
They will rather send a Tesla. "First Tesla on another planet".. Actually they could do this (launch a rocket) this week..
-
Brain rebuilding?
Depends on what do you mean by the "structure fundamentally similar".. ..you should search for articles on comparing MRI scans of twins..
-
Problems using bluetooth to check distance between users ?
Bluetooth works reliablely only a few meters. If you run app in continuous BT discovery mode the all other devices with enabled BT will be captured (unless they have disabled BT, or enabled airplane mode). So app knows which devices (and indirectly which people) were around you (and their phone's BT MAC addresses). And if person is ill the all people with close proximity (5-10m) will be identified (if government app would send MAC address to central server). The problem with this method is that the all people have to have smartphone, and all have to have installed application, and must have battery fully charged, and never exhaust it.. continuous usage of BT drains battery very quickly. To make application work, device can't go to sleep mode. My device especially not liking WiFi, and GPS, but BT is third to drain battery.. Obviously there is (well deserved!) reluctance from democratic countries people concerning about their privacy. Therefore even Android app which asks for Bluetooth permission also requires coarse location permission, since Android v10, fine location permission, and since Android v11, background location permission. As a side note, if you have WiFi turned on, Hotspot mode or not, MAC address can also identify your device (it is unique in the world). But WiFi and BT have different MAC addresses. So, entire idea of usage of BT could work only in totalitarian country, like North Korea etc. (if they would have electronic devices and electricity all day long)
-
A Simple Arithmetic Teaser !
Not for me..