https://fuchsia.googlesource.com/fuchsia/+/master/docs/README.md
https://fuchsia.googlesource.com/fuchsia/+/master/docs/the-book/README.md#User-interface
Monday, May 20, 2019
Tuesday, May 14, 2019
PLA, PAL , CPLD, FPGA
In the earlier 60's it was discrete logic used by electronic industry. The digital system would look like noodle like maze of wiring between components. Once it is built it will be difficult to do rework on it. Sometimes the designers would forget what they have designed for! Manufacturing such systems was very difficult and redesign will be so eye-shutting just like making a PCB every time we redesign. The chip manufactures resolved this issue by placing an unconnected array of AND-OR gates in a single chip device called a programmable logic device (PLD).
Reference: http://www.circuitstoday.com/understanding-fpga-and-cpld
ROM, PLA & PAL
The first PLD was ROM. ROM design was not very successful as it emerged the issue of hardware wastage and increasing exponential growth in the hardware for every large application. To overcome the limitations of ROM, PLA and PAL were devised.
PLA and PAL are types of Programmable Logic Devices (PLD) which are used to design combination logic together with sequential logic. The significant difference between the PLA and PAL is that the PLA consists of the programmable array of AND and OR gates while PAL has the programmable array of AND but a fixed array of OR gate.
Definition of PLA
PLA stands for the Programmable Logic Array which presents the boolean function in the SOP (Sum of Products) form. The PLA contains NOT, AND and OR gates fabricated on the chip. It passes every input by a NOT gate which makes each input and its complement available to every AND gate. The output of each AND gate is given to the each OR gate. At last, the OR gate output produces chip output. So, this is how suitable connections are made to employ SOP expressions.
In PLA the connections to both AND and OR arrays are programmable. PLA is considered more expensive and complex as compared to the PAL. The two different manufacturing techniques can be used for PLA to increase the ease of programming. In this technique, each connection is built through a fuse at every intersection point where the unwanted connections can be removed by blowing the fuses. The latter technique involves the connection making at the time of the fabrication process with the help of the proper mask provided for the specific interconnection pattern.
Definition of PAL
PAL (Programmable Array Logic) is also a PLD (Programmable Logic Device) circuit which works similar to the PLA. PAL employs the programmable AND gates but fixed OR gates, unlike PLA. It implements two simple functions where the number of linked AND gates to each OR gate specifies the maximum number of product terms that can be generated in a sum-of-products representation of the particular function. While the AND gates are perpetually connected to the OR gates, which signifies that the produced product term is not shareable with the output functions.
The main concept behind developing PLD’s is to embed a complex boolean logic into a single chip. Therefore, eliminating the unreliable wiring, preventing the logic design and minimizing power consumption.
Reference: https://techdifferences.com/difference-between-pla-and-pal.html
A CPLD contains a bunch of PLD blocks whose inputs and outputs are connected together by a global interconnection matrix. So a CPLD has two levels of programmability: each PLD block can be programmed, and then the interconnections between the PLDs can be programmed.
An FPGA takes a different idea. It has a clump of simple, configurable logic blocks arranged in an array with interspersed switches that can rearrange the interconnections between the logic blocks. Each logic block is individually programmed to perform a logic function (such as AND, OR, XOR, etc.) and then the switches are programmed to connect the blocks so that the complete logic functions are implemented.
Reference: http://www.circuitstoday.com/understanding-fpga-and-cpld
ROM, PLA & PAL
The first PLD was ROM. ROM design was not very successful as it emerged the issue of hardware wastage and increasing exponential growth in the hardware for every large application. To overcome the limitations of ROM, PLA and PAL were devised.
PLA and PAL are types of Programmable Logic Devices (PLD) which are used to design combination logic together with sequential logic. The significant difference between the PLA and PAL is that the PLA consists of the programmable array of AND and OR gates while PAL has the programmable array of AND but a fixed array of OR gate.
BASIS FOR COMPARISON | PLA | PAL |
---|---|---|
Stands for | Programmable Logic Array | Programmable Array Logic |
Construction | Programmable array of AND and OR gates. | Programmable array of AND gates and fixed array of OR gates. |
Availability | Less prolific | More readily available |
Flexibility | Provides more programming flexibility. | Offers less flexibility, but more likely used. |
Cost | Expensive | Intermediate cost |
Number of functions | Large number of functions can be implemented. | Provides the limited number of functions. |
Speed | Slow | High |
Definition of PLA
PLA stands for the Programmable Logic Array which presents the boolean function in the SOP (Sum of Products) form. The PLA contains NOT, AND and OR gates fabricated on the chip. It passes every input by a NOT gate which makes each input and its complement available to every AND gate. The output of each AND gate is given to the each OR gate. At last, the OR gate output produces chip output. So, this is how suitable connections are made to employ SOP expressions.
In PLA the connections to both AND and OR arrays are programmable. PLA is considered more expensive and complex as compared to the PAL. The two different manufacturing techniques can be used for PLA to increase the ease of programming. In this technique, each connection is built through a fuse at every intersection point where the unwanted connections can be removed by blowing the fuses. The latter technique involves the connection making at the time of the fabrication process with the help of the proper mask provided for the specific interconnection pattern.
Definition of PAL
PAL (Programmable Array Logic) is also a PLD (Programmable Logic Device) circuit which works similar to the PLA. PAL employs the programmable AND gates but fixed OR gates, unlike PLA. It implements two simple functions where the number of linked AND gates to each OR gate specifies the maximum number of product terms that can be generated in a sum-of-products representation of the particular function. While the AND gates are perpetually connected to the OR gates, which signifies that the produced product term is not shareable with the output functions.
The main concept behind developing PLD’s is to embed a complex boolean logic into a single chip. Therefore, eliminating the unreliable wiring, preventing the logic design and minimizing power consumption.
Reference: https://techdifferences.com/difference-between-pla-and-pal.html
A CPLD contains a bunch of PLD blocks whose inputs and outputs are connected together by a global interconnection matrix. So a CPLD has two levels of programmability: each PLD block can be programmed, and then the interconnections between the PLDs can be programmed.
An FPGA takes a different idea. It has a clump of simple, configurable logic blocks arranged in an array with interspersed switches that can rearrange the interconnections between the logic blocks. Each logic block is individually programmed to perform a logic function (such as AND, OR, XOR, etc.) and then the switches are programmed to connect the blocks so that the complete logic functions are implemented.
FPGA
|
CPLD
|
Suited for timing circuit because they have more registers. | CPLD is suited for control circuit because they have more combinational circuit. |
Timing reports will be different if same code is synthesized many times. | Timing reports will be same result. |
FPGA can be used to high-end product | CPLD can be used to low-end product |
FPGA has more flexibility as well as design capacity. | CPLD has less compared to FPGA regarding design complexity |
FPGA can operate at very high speed | CPLD has less |
The FPGA are volatile in many cases, that’s way they need a configuration memory for working with programmed design. | CPLD devices are not volatile. They contain flash or erasable ROM memory in all of cases. |
FPGA could not work untill the configuration is done. | The CPLD could work immediately after power up. |
FPGA is RAM base. | CPLD is ROM base. |
FPGAs are “fine-grain” devices. That means that they contain a lot (up to 100000) of tiny blocks of logic with flip-flops. | CPLDs are “coarse-grain” devices. They contain relatively few (a few 100’s max) large blocks of logic with flip-flops. |
FPGAs have special routing resources to implement efficiently binary counters and arithmetic functions (adders, comparators…). CPLDs do not. | CPLDs have a faster input-to-output timings than FPGAs (because of their coarse-grain architecture, one block of logic can hold a big equation), so are better suited for microprocessor decoding logic for example than FPGAs. |
FPGAs can contain very large digital designs | CPLDs can contain small designs only. |
Tuesday, April 23, 2019
TCP and UDP
TCP and UDP
Both TCP and UDP are protocols used for sending bits of data — known as packets — over the Internet. They both build on top of the Internet protocol. In other words, whether you are sending a packet via TCP or UDP, that packet is sent to an IP address. These packets are treated similarly, as they are forwarded from your computer to intermediary routers and on to the destination.
TCP and UDP are not the only protocols that work on top of IP. However, they are the most widely used. The widely used term “TCP/IP” refers to TCP over IP. UDP over IP could just as well be referred to as “UDP/IP”, although this is not a common term.
TCP
TCP stands for Transmission Control Protocol. It is the most commonly used protocol on the Internet.
When you load a web page, your computer sends TCP packets to the web server’s address, asking it to send the web page to you. The web server responds by sending a stream of TCP packets, which your web browser stitches together to form the web page and display it to you. When you click a link, sign in, post a comment, or do anything else, your web browser sends TCP packets to the server and the server sends TCP packets back. TCP is not just one way communication — the remote system sends packets back to acknowledge it is received your packets.
TCP guarantees the recipient will receive the packets in order by numbering them. The recipient sends messages back to the sender saying it received the messages. If the sender does not get a correct response, it will resend the packets to ensure the recipient received them. Packets are also checked for errors. TCP is all about this reliability — packets sent with TCP are tracked so no data is lost or corrupted in transit. This is why file downloads do not become corrupted even if there are network hiccups. Of course, if the recipient is completely offline, your computer will give up and you will see an error message saying it can not communicate with the remote host.
UDP
UDP stands for User Datagram Protocol — a datagram is the same thing as a packet of information. The UDP protocol works similarly to TCP, but it throws all the error-checking stuff out. All the back-and-forth communication and deliverability guarantees slow things down.
When using UDP, packets are just sent to the recipient. The sender will not wait to make sure the recipient received the packet — it will just continue sending the next packets. If you are the recipient and you miss some UDP packets, too bad — you can not ask for those packets again. There is no guarantee you are getting all the packets and there is no way to ask for a packet again if you miss it, but losing all this overhead means the computers can communicate more quickly.
UDP is used when speed is desirable and error correction is not necessary. For example, UDP is frequently used for live broadcasts and online games.
TCP vs UDP
TCP (Transmission Control Protocol) is connection oriented, whereas UDP (User Datagram Protocol) is connection-less. This means that TCP tracks all data sent, requiring acknowledgment for each octet (generally). UDP does not use acknowledgments at all, and is usually used for protocols where a few lost datagrams do not matter.
Because of acknowledgments, TCP is considered a reliable data transfer protocol. It ensures that no data is sent to the upper layer application that is out of order, duplicated, or has missing pieces. It can even manage transmissions to attempt to reduce congestion.
UDP is a very lightweight protocol defined in RFC 768. The primary uses for UDP include service advertisements, such as routing protocol updates and server availability, one-to-many multicast applications, and streaming applications, such as voice and video, where a lost datagram is far less important than an out-of-order datagram.
Reference https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Both TCP and UDP are protocols used for sending bits of data — known as packets — over the Internet. They both build on top of the Internet protocol. In other words, whether you are sending a packet via TCP or UDP, that packet is sent to an IP address. These packets are treated similarly, as they are forwarded from your computer to intermediary routers and on to the destination.
TCP and UDP are not the only protocols that work on top of IP. However, they are the most widely used. The widely used term “TCP/IP” refers to TCP over IP. UDP over IP could just as well be referred to as “UDP/IP”, although this is not a common term.
TCP
TCP stands for Transmission Control Protocol. It is the most commonly used protocol on the Internet.
When you load a web page, your computer sends TCP packets to the web server’s address, asking it to send the web page to you. The web server responds by sending a stream of TCP packets, which your web browser stitches together to form the web page and display it to you. When you click a link, sign in, post a comment, or do anything else, your web browser sends TCP packets to the server and the server sends TCP packets back. TCP is not just one way communication — the remote system sends packets back to acknowledge it is received your packets.
TCP guarantees the recipient will receive the packets in order by numbering them. The recipient sends messages back to the sender saying it received the messages. If the sender does not get a correct response, it will resend the packets to ensure the recipient received them. Packets are also checked for errors. TCP is all about this reliability — packets sent with TCP are tracked so no data is lost or corrupted in transit. This is why file downloads do not become corrupted even if there are network hiccups. Of course, if the recipient is completely offline, your computer will give up and you will see an error message saying it can not communicate with the remote host.
UDP
UDP stands for User Datagram Protocol — a datagram is the same thing as a packet of information. The UDP protocol works similarly to TCP, but it throws all the error-checking stuff out. All the back-and-forth communication and deliverability guarantees slow things down.
When using UDP, packets are just sent to the recipient. The sender will not wait to make sure the recipient received the packet — it will just continue sending the next packets. If you are the recipient and you miss some UDP packets, too bad — you can not ask for those packets again. There is no guarantee you are getting all the packets and there is no way to ask for a packet again if you miss it, but losing all this overhead means the computers can communicate more quickly.
UDP is used when speed is desirable and error correction is not necessary. For example, UDP is frequently used for live broadcasts and online games.
TCP vs UDP
TCP (Transmission Control Protocol) is connection oriented, whereas UDP (User Datagram Protocol) is connection-less. This means that TCP tracks all data sent, requiring acknowledgment for each octet (generally). UDP does not use acknowledgments at all, and is usually used for protocols where a few lost datagrams do not matter.
Because of acknowledgments, TCP is considered a reliable data transfer protocol. It ensures that no data is sent to the upper layer application that is out of order, duplicated, or has missing pieces. It can even manage transmissions to attempt to reduce congestion.
UDP is a very lightweight protocol defined in RFC 768. The primary uses for UDP include service advertisements, such as routing protocol updates and server availability, one-to-many multicast applications, and streaming applications, such as voice and video, where a lost datagram is far less important than an out-of-order datagram.
Reference https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Create an instant messager
How to create an instant messager like whatsapp
Erlang: This is the chief programming language used to develop the epic chat app Whatsapp. The Erlang programming language was most appreciated for its performance reasons, speed and scalability.
Ejabberd: open source jabber resembles (WhatsApp clone); XMPP (Extensible Messaging and Presence Protocol) protocol to handle the message delivery system over on any local area network or the Internet.The Ejabberd server is developed using certain pluggable modules which enables wide features such as:
One-on-one Chat
Contact actual and presence listing
Store and forward (Offline messages)
Personal Event Protocol (PEP) and Message typing specification
Multi-User Chat (MUC) — Group Chat
Privacy Setting and Account Spoofing
Message Archive Management (MAM)
FreeBSD: WhatsApp, which has sent over billions of messages every day on its platform, has been built on FreeBSD.The FreeBSD being a single distributor have many advantages with Installation and provided easy creation of binary packages.
YAWS: (Yet Another Web Server) is written entirely in Erlang. YAWS runs as an embedded web server on the combination in another Erlang application.
Lighttpd: Lighttpd is an open source web server. The lightweight web server is deployed on WhatsApp to acquire a secure, flexible, fast and compliant feature.
PHP: PHP is an open source language . In combination with AJAX, a powerful web development technology to display data from the database using Ajax to develop responsive real-time chat app.
BEAM: BEAM is a virtual machine to run the Erlang. It is a bunch of built-in functions such as if-simple network interface tool. BEAM interface to support the functions — Schedulers, Processes, Message passing, Memory Management and Multi-core etc.
Custom XMPP Server: Whatsapp encoded XMPP server to its functionality by reducing the byte of the keywords. The technology is used to enable message exchange in a real-time. The XML format is a human-oriented and it’s not meant to be read by any machine learning.
HTML5 WebSockets: The WebSocket is a feature in HTML5 used to establish a solid connection between the web browser and the server. The WebSocket data are directly sent over a socket which provides faster and persistent communication between the server and web browser.
Mnesia DB: This is a real-time database management system written in the Erlang language. Mnesia is a soft database that allows for store the messages, files, images, videos, documents and the rest multimedia files that running on your app. This is a kind of technology that goes beyond your expectation that has the potential to store any amount of data.
Reference https://hackernoon.com/how-to-build-your-own-real-time-chat-app-like-whatsapp-9d1d058afd5b
Reference https://octodev.net/how-to-develop-a-chat-app-like-whatsapp/
Reference https://medium.com/swlh/lets-write-a-chat-app-in-python-f6783a9ac170
Reference https://towhidz.wordpress.com/2012/03/03/simple-chat-applicationclient-server-in-android/
Erlang: This is the chief programming language used to develop the epic chat app Whatsapp. The Erlang programming language was most appreciated for its performance reasons, speed and scalability.
Ejabberd: open source jabber resembles (WhatsApp clone); XMPP (Extensible Messaging and Presence Protocol) protocol to handle the message delivery system over on any local area network or the Internet.The Ejabberd server is developed using certain pluggable modules which enables wide features such as:
One-on-one Chat
Contact actual and presence listing
Store and forward (Offline messages)
Personal Event Protocol (PEP) and Message typing specification
Multi-User Chat (MUC) — Group Chat
Privacy Setting and Account Spoofing
Message Archive Management (MAM)
FreeBSD: WhatsApp, which has sent over billions of messages every day on its platform, has been built on FreeBSD.The FreeBSD being a single distributor have many advantages with Installation and provided easy creation of binary packages.
YAWS: (Yet Another Web Server) is written entirely in Erlang. YAWS runs as an embedded web server on the combination in another Erlang application.
Lighttpd: Lighttpd is an open source web server. The lightweight web server is deployed on WhatsApp to acquire a secure, flexible, fast and compliant feature.
PHP: PHP is an open source language . In combination with AJAX, a powerful web development technology to display data from the database using Ajax to develop responsive real-time chat app.
BEAM: BEAM is a virtual machine to run the Erlang. It is a bunch of built-in functions such as if-simple network interface tool. BEAM interface to support the functions — Schedulers, Processes, Message passing, Memory Management and Multi-core etc.
Custom XMPP Server: Whatsapp encoded XMPP server to its functionality by reducing the byte of the keywords. The technology is used to enable message exchange in a real-time. The XML format is a human-oriented and it’s not meant to be read by any machine learning.
HTML5 WebSockets: The WebSocket is a feature in HTML5 used to establish a solid connection between the web browser and the server. The WebSocket data are directly sent over a socket which provides faster and persistent communication between the server and web browser.
Mnesia DB: This is a real-time database management system written in the Erlang language. Mnesia is a soft database that allows for store the messages, files, images, videos, documents and the rest multimedia files that running on your app. This is a kind of technology that goes beyond your expectation that has the potential to store any amount of data.
Reference https://hackernoon.com/how-to-build-your-own-real-time-chat-app-like-whatsapp-9d1d058afd5b
Reference https://octodev.net/how-to-develop-a-chat-app-like-whatsapp/
Create an instant messager with Python
Reference https://medium.com/swlh/lets-write-a-chat-app-in-python-f6783a9ac170
Create an instant messager with Java
Reference https://towhidz.wordpress.com/2012/03/03/simple-chat-applicationclient-server-in-android/
Selenium in Python
Selenium Waiting
Time
強制等待。莫論Browser是否完成前程序,也要等待指定間到後才執行。
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.get('https://www.google.com')
sleep(3) # Wait for 3 seconds
print (driver.current_url)
print (driver.page_source)
driver.quit()
Implicitly_wait
隱性等待。等待Browser 指定時間 或 Browser完成前程序便即時執行下一個程序。
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.get('https://www.google.com')
driver.implicitly_wait(30) # Wait for 30 seconds or util broswer finished loading
print (driver.current_url)
print (driver.page_source)
driver.quit()
WebDriverWait
配合使用 until() 及 until_not(),按條件等待。
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import sleep
driver = webdriver.Chrome()
driver.get('https://www.google.com')
driver.implicitly_wait(30) # Wait for 30 seconds or util broswer finished loading
locator = (By.LINK_TEXT, 'CSDN')
try:
WebDriverWait(driver, 20, 0.5).until(EC.presence_of_element_located(locator))
print driver.find_element_by_link_text('CSDN').get_attribute('href')
finally:
driver.close()
Reference
https://huilansame.github.io/huilansame.github.io/archivers/sleep-implicitlywait-wait
Wednesday, April 17, 2019
Java Number & Math
Math in Java
Input
public class test{
public static void main(String[] args){
System.out.println("sin:" + Math.sin(Math.PI/2));
System.out.println("cos:" + Math.cos(0));
System.out.println("tan:" + Math.tan(Math.PI/3));
System.out.println("atan:" + Math.atan(1));
System.out.println("toDegrees:" + Math.toDegrees(Math.PI/2));
System.out.println(Math.PI);
}
}
Output
D:\javafiles>java test.java
sin:1.0
cos:1.0
tan:1.7320508075688767
atan:0.7853981633974483
toDegrees:90.0
3.141592653589793
sin:1.0
cos:1.0
tan:1.7320508075688767
atan:0.7853981633974483
toDegrees:90.0
3.141592653589793
----------
Java xxxValue()
Input
class test{
public static void main(String[] args){
Integer x = 5;
System.out.println(x.byteValue());
System.out.println(x.doubleValue());
System.out.println(x.floatValue());
System.out.println(x.intValue());
System.out.println(x.longValue());
System.out.println(x.shortValue());
}
}
Output
D:\javafiles>java test.java
5
5.0
5.0
5
5
5
D:\javafiles>java test.java
5
5.0
5.0
5
5
5
Reference: http://www.runoob.com/java/number-xxxvalue.html----------
Java compareTo()
Input
public class test{
public static void main(String args[]){
Integer x = 5;
System.out.println(x.compareTo(3));
System.out.println(x.compareTo(5));
System.out.println(x.compareTo(8));
}
}
Output
D:\javafiles>java test.java
false
true
false
Reference: http://www.runoob.com/java/number-compareto.html
----------
Java equals()
Input
public class Test{
public static void main(String args[]){
public static void main(String args[]){
Integer x = 5;
Integer y = 10;
Integer z =5;
Short a = 5;
System.out.println(x.equals(y));
System.out.println(x.equals(z));
System.out.println(x.equals(a));
}
}
Output
D:\javafiles>java test.java
false
true
false
Reference: http://www.runoob.com/java/number-equals.html
----------
Java valueOf()
Input
public class test{
public static void main(String[] args){
Integer x =Integer.valueOf(9);
Double c = Double.valueOf(5);
Float a = Float.valueOf("80");
Integer b = Integer.valueOf("444",16); //16 means use Hexadecimal
System.out.println(x);
System.out.println(c);
System.out.println(a);
System.out.println(b);
}
}
Output
D:\javafiles>java test.java
9
5.0
80.0
1092
Reference: http://www.runoob.com/java/number-valueof.html
----------
Java toString()
Input
public class test{
public static void main(String[] args){
Integer x = 5;
System.out.println(x.toString());
System.out.println(Integer.toString(12));
}
}
Output
D:\javafiles>java test.java
5
12
Reference: http://www.runoob.com/java/number-tostring.html
----------
Java parseInt()
Input
public class test{
public static void main(String[] args){
int x =Integer.parseInt("9");
double c = Double.parseDouble("5");
int b = Integer.parseInt("444",16);
System.out.println(x);
System.out.println(c);
System.out.println(b);
}
}
Output
D:\javafiles>java test.java
9
5.0
1092
Reference: http://www.runoob.com/java/number-parseInt.html
---------
Java abs()
Input
public class test{
public static void main(String[] args){
Integer a = -8;
double d = -100;
float f = -90;
System.out.println(Math.abs(a));
System.out.println(Math.abs(d));
System.out.println(Math.abs(f));
}
}
Output
D:\javafiles>java test.java
8
100.0
90.0
Reference: http://www.runoob.com/java/number-abs.html
---------
Java ceil() & floor()
Input
public class test{
public static void main(String[] args){
double d = 100.675;
float f = -90;
System.out.println(Math.ceil(d));
System.out.println(Math.ceil(f));
System.out.println(Math.floor(d));
System.out.println(Math.floor(f));
}
}
D:\javafiles>java test.java
101.0
-90.0
100.0
-90.0
Reference: http://www.runoob.com/java/number-ceil.html
---------
Java rint()
Input
public class test{
public static void main(String[] args){
double d = 100.675;
double e = 100.500;
double f = 100.200;
System.out.println(Math.rint(d));
System.out.println(Math.rint(e));
System.out.println(Math.rint(f));
}
}
Output
D:\javafiles>java test.java
101.0
100.0
100.0
Reference: http://www.runoob.com/java/number-rint.html
---------
Java round()
Input
public class test{
public static void main(String[] args){
double d = 100.675;
double e = 100.500;
float f = 100;
float g = 90f;
System.out.println(Math.round(d));
System.out.println(Math.round(e));
System.out.println(Math.round(f));
System.out.println(Math.round(g));
}
}
Output
D:\javafiles>java test.java
101
101
100
90
Reference: http://www.runoob.com/java/number-round.html
---------
Java min()
Input
public class test{
public static void main(String[] args){
System.out.println(Math.min(12.123, 12.456));
System.out.println(Math.min(23.12, 23.0));
}
}
Output
D:\javafiles>java test.java
12.123
23.0
Reference: http://www.runoob.com/java/number-min.html
---------
Java max()
Input
public class test{
public static void main(String[] args){
System.out.println(Math.max(12.123, 18.456));
System.out.println(Math.max(23.12, 23.0));
}
}
D:\javafiles>java test.java
18.456
23.12
Reference: http://www.runoob.com/java/number-max.html
---------
Java exp()
Input
public class test{
public static void main(String[] args){
double x = 11.635;
double y = 2.76;
System.out.printf("Value of e : %.4f%n", Math.E);
System.out.printf("Value of exp(%.3f) : %.3f%n", x, Math.exp(x));
}
}
Output
D:\javafiles>java test.java
Value of e : 2.7183
Value of exp(11.635) : 112983.831
Reference: http://www.runoob.com/java/number-exp.html
---------
Java log()
Input
public class test{
public static void main(String[] args){
double x = 11.635;
double y = 2.76;
System.out.printf("Value of e : %.4f%n", Math.E);
System.out.printf("Value of log(%.3f) : %.3f%n", x, Math.log(x));
}
}
Output
D:\javafiles>java test.java
Value of e : 2.7183
Value of log(11.635) : 2.454
Reference: http://www.runoob.com/java/number-log.html
---------
Java pow()
Input
public class test{
public static void main(String[] args){
double x = 11.635;
double y = 2.76;
System.out.printf("Value of e : %.4f%n", Math.E);
System.out.printf("Value of pow(%.3f, %.3f): %.3f%n", x, y, Math.pow(x, y));
}
}
Output
D:\javafiles>java test.java
Value of e : 2.7183
Value of pow(11.635, 2.760): 874.008
Reference:http://www.runoob.com/java/number-pow.html
---------
Java sqrt()
Input
public class test{
public static void main(String[] args){
double x = 11.635;
double y = 2.76;
System.out.printf("Value of e: %.4f%n", Math.E);
System.out.printf("Value of sqrt(%.3f): %.3f%n", x, Math.sqrt(x));
}
}
Output
D:\javafiles>java test.java
Value of e: 2.7183
Value of sqrt(11.635): 3.411
Reference: http://www.runoob.com/java/number-sqrt.html
---------
Java random()
Input
public class test{
public static void main(String[] args){
System.out.println( Math.random() );
System.out.println( Math.random() );
}
}
Output
D:\javafiles>java test.java
0.7514961840542885
0.36280573195436616
Reference: http://www.runoob.com/java/number-random.html
---------
Sunday, April 14, 2019
2019 Easy guide for Java - Installation and setup
Setup and Install Flow
Since I need to install Java at my company laptop for writing some easy program to help my works. (Also for learning and fun) However, I faced so many problems during setup and install the Java. Here is a record for the flow and problem faced for future reference. Hopefully it helps those visitors from all over the world who face similar problems.
As my laptop is using Windows 7, so all the procedures below are the setup process for Windows 7. I do the same with another laptop that using Windows 10. Probably the setup procedure are somehow the same.
1.) Download Java JDK and Java JRE
If you want to drink coffee, of course you need to buy or make a cup of coffee. If you need play with Java, you need not buy but could download for free from the Internet. At the moment, Java is owned by Oracle so we could download it officially from Oracle official page.
https://www.oracle.com/technetwork/java/javase/downloads/index.html
For JDK (Java Development Kit) , there are a few options: JavaSE, JavaEE, JavaME...etc. What's the difference amount these versions?
JavaSE is Standard Edition.
JavaEE is Enterprise Edition
JavaME is Micro Edition
Go https://stackoverflow.com/questions/2857376/difference-between-java-se-ee-me to see more.
As a normal user, I download the SE edition. The latest JavaSE version is 12. For easy handling, I just download the jdk-12_windows-x64_bin.exe. Just Download and double click the downloaded file, follow the steps and everything got done.
Beside of JDK, we also need the JRE (Java Runtime Environment). Why we need the runtime environment? If you ask this question, you probably have no idea how java works, so am I. You can go https://www.geeksforgeeks.org/differences-jdk-jre-jvm/ to learn more.
So where to download the JRE? You can go here:
https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
At the moment, there are two latest JRE version: 8u201 and 8u202. Some people says that the bigger number is the best options, however, it may not be the case. Actually it is about CPU(Critical Patch Update) and PSU(Patch Set Update). Go https://www.oracle.com/technetwork/java/javase/cpu-psu-explained-2331472.htmlto know more. Although the link is for an old version Java, it also clarify the difference for two versions.
For me, I downloaded 8u201 version.
2.) Install
Once download the two JDK and JRE installation files, just open the files and follow the guild to install JavaSE (JDK) and Java JRE.
Here are problems i faced during installation
Problem 1 - changed install location not workable
The preset install location for JDK is
C:\Program Files\Java\ jdk-12 (folder name depends on version) \
and JRE is
C:\Program Files\Java\jre1.8.0_201(folder name depends on version) \
However, I had changed the path to D: during my first installation. It makes me lots of trouble. I tried every solution e.g. set the correct variable environment and every possible but it still not work. Therefore, for beginner it's not recommended change the suggested installation path.
Problem 2 - Path setting
As a Windows user, we need to set the environment variable. Go https://www.java.com/en/download/help/path.xml to learn how to set environment variable.
Still can't run java after setting the environment, there are many reasons for not working.
Go https://stackoverflow.com/questions/4419983/a-jre-or-jdk-must-be-available-in-order-to-run-eclipse-no-jvm-was-found-after-s and https://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7to know more.
Also, in environment variable, always put JDK/bin in priority and next JRE/bin. I have no idea the reasons but it works for me once i reset JDK/bin on top.
Since I need to install Java at my company laptop for writing some easy program to help my works. (Also for learning and fun) However, I faced so many problems during setup and install the Java. Here is a record for the flow and problem faced for future reference. Hopefully it helps those visitors from all over the world who face similar problems.
As my laptop is using Windows 7, so all the procedures below are the setup process for Windows 7. I do the same with another laptop that using Windows 10. Probably the setup procedure are somehow the same.
1.) Download Java JDK and Java JRE
If you want to drink coffee, of course you need to buy or make a cup of coffee. If you need play with Java, you need not buy but could download for free from the Internet. At the moment, Java is owned by Oracle so we could download it officially from Oracle official page.
https://www.oracle.com/technetwork/java/javase/downloads/index.html
For JDK (Java Development Kit) , there are a few options: JavaSE, JavaEE, JavaME...etc. What's the difference amount these versions?
JavaSE is Standard Edition.
JavaEE is Enterprise Edition
JavaME is Micro Edition
Go https://stackoverflow.com/questions/2857376/difference-between-java-se-ee-me to see more.
As a normal user, I download the SE edition. The latest JavaSE version is 12. For easy handling, I just download the jdk-12_windows-x64_bin.exe. Just Download and double click the downloaded file, follow the steps and everything got done.
Beside of JDK, we also need the JRE (Java Runtime Environment). Why we need the runtime environment? If you ask this question, you probably have no idea how java works, so am I. You can go https://www.geeksforgeeks.org/differences-jdk-jre-jvm/ to learn more.
So where to download the JRE? You can go here:
https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
At the moment, there are two latest JRE version: 8u201 and 8u202. Some people says that the bigger number is the best options, however, it may not be the case. Actually it is about CPU(Critical Patch Update) and PSU(Patch Set Update). Go https://www.oracle.com/technetwork/java/javase/cpu-psu-explained-2331472.htmlto know more. Although the link is for an old version Java, it also clarify the difference for two versions.
For me, I downloaded 8u201 version.
2.) Install
Once download the two JDK and JRE installation files, just open the files and follow the guild to install JavaSE (JDK) and Java JRE.
Here are problems i faced during installation
Problem 1 - changed install location not workable
The preset install location for JDK is
C:\Program Files\Java\ jdk-12 (folder name depends on version) \
and JRE is
C:\Program Files\Java\jre1.8.0_201(folder name depends on version) \
However, I had changed the path to D: during my first installation. It makes me lots of trouble. I tried every solution e.g. set the correct variable environment and every possible but it still not work. Therefore, for beginner it's not recommended change the suggested installation path.
Problem 2 - Path setting
As a Windows user, we need to set the environment variable. Go https://www.java.com/en/download/help/path.xml to learn how to set environment variable.
Still can't run java after setting the environment, there are many reasons for not working.
Go https://stackoverflow.com/questions/4419983/a-jre-or-jdk-must-be-available-in-order-to-run-eclipse-no-jvm-was-found-after-s and https://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7to know more.
Also, in environment variable, always put JDK/bin in priority and next JRE/bin. I have no idea the reasons but it works for me once i reset JDK/bin on top.
Thursday, January 31, 2019
Fruits in Australia
Sydney
Spring
Cherries, lemons, mandarins, nectarines, oranges, peaches, plums, strawberries
Summer
Apricots, berries, melons, nectarines, peaches, plums, and strawberries
Autumn
Apples, berries, kiwifruit, pears, persimmons, strawberries
Winter
Lemons, mandarins, oranges
Melbourne
Spring
Bananas, berries, grapefruit, lemons, limes, imperial mandarins, strawberries
Summer
Apricots, bananas, berries, cherries, figs, grapefruit, grapes, melons, Valencia oranges, peaches, pears, plums, strawberries
Autumn
Apples, bananas, figs, grapefruit, grapes, imperial mandarins, melons, Valencia oranges, pears, strawberries
Winter
Apples, bananas, grapefruit, kiwifruit, lemons, limes, imperial mandarins, Navel oranges, pears
Brisbane
Spring
Red apples, green apples, avocados, bananas, blueberries, carambola, coconuts, custard apples, dates, dragon fruit, gooseberries, green grapes, grapefruit, guava, honeydew melons, kiwifruit, lemons, limes, mandarins, mangoes, nectarines, oranges, passion fruit, Paw Paw, peaches, pears, pineapples, pomegranate, raspberries, rock melons, strawberries, tamarillo, watermelon.
Summer
Red apples, green apples, apricots, avocados, bananas, blackberries, blueberries, carambola, cherries, coconuts, dates, dragon fruit, figs, gooseberries, red grapes, green grapes, grapefruit, guava, honeydew melons, kiwifruit, lemons, limes, loganberries, lychees, mangoes, mangosteen, nectarines, oranges, passion fruit, paw paw, peaches, pears, pineapples, plums, pomegranate, rambutan, raspberries, rock melons, rosella, strawberries, tamarillo, watermelon.
Autumn
Red apples, green apples, avocados, bananas, blueberries, breadfruit, carambola, coconut, cumquats, custard apples, dates, dragon fruit, figs, grapefruit, guava, honeydew melons, kiwifruit, lemons, limes, mandarins, mangosteen, nectarines, olives, oranges, passion fruit, paw paw, pears, persimmons, pineapples, plums, pomegranate, quince, rambutan, raspberries, rock melons, rosella, strawberries, watermelon.
Winter
Red apples, green apples, avocados, bananas, breadfruit, carambola, cherries, coconuts, custard apples, dates, dragonfruit, grapefruit, guava, honeydew melons, kiwifruit, lemons, limes, mandarins, olives, oranges, passionfruit, paw paw, pears, persimmons, pineapples, pomegranate, rockmelons, strawberries, tamarillo, tangelo, watermelon.
Perth
Spring
Avocadoes, bananas, berries, blueberries, currants, figs, limes, loquats, mandarins, mangoes, honeydew melons, mulberries, nectarines, Valencia oranges, passion fruit, paw paw, strawberries.
Summer
Royal Gala apples, apricots, avocadoes, bananas, cherries, grapes, mangoes, rock melons, watermelons, nectarines, passion fruit, Paw Paw, peaches, plums, strawberries.
Autumn
Apples (Fuji, Golden Delicious, Granny Smith, Hi Early, Jonathan), bananas, custard apples, figs, grapes, guavas, kiwifruit, cumquats, mandarins, rock melons, watermelons, Nashi pears, olives, Paw Paw, passion fruit, pears, quinces.
Winter
Apples (Lady Williams, Pink Lady, Sundowner), avocadoes, bananas, grapefruit, kiwifruit, cumquats, limes, mandarins, honeydew melons, Nashi pears, Navel oranges, paw paw
Adelaide
Spring
Apples, avocadoes, grapefruit, lemons, limes, loquats, mandarins, pears, rhubarb, strawberries, tangelos, tangerines.
Summer
Apricots, avocadoes, blackberries, cherries, honeydew melons, loquats, peaches, plums, raspberries, rhubarb, rock melon, strawberries, watermelons
Autumn
Apples, blackberries, figs, grapes, honeydew melons, limes, mandarins, Valencia oranges, passionfruit, pears, persimmons, plums, pomegranate, quinces, raspberries, rhubarb, rock melons, strawberries, watermelons.
Winter
Apples, avocadoes, grapefruit, lemons, limes, mandarins, Navel oranges, pears, persimmons, quinces, rhubarb, tangelos, tangerines.
Reference
Export Calender: Austfruits Export Calender
Subscribe to:
Posts (Atom)