Skip to content

Instantly share code, notes, and snippets.

View tom4i's full-sized avatar
🐍
2025

Tom Zhu tom4i

🐍
2025
View GitHub Profile
public class Test {
public static void main(String[] args) {
double d = 756.2345566;
//方法一:最简便的方法,调用DecimalFormat类
DecimalFormat df = new DecimalFormat(".00");
System.out.println(df.format(d));
//方法二:直接通过String类的format函数实现
System.out.println(String.format("%.2f", d));
@tom4i
tom4i / BroadcastObservable.java
Created October 24, 2016 15:46 — forked from Diolor/BroadcastObservable.java
Retry with Connection
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Looper;
import rx.Observable;
import rx.Scheduler;
#include <iostream>
#include <string>
#include <QCoreApplication>
using namespace std;
/**
* Type: Tower
* -------------
* This structure contains the name of the tower and a link to the next one.
*/
@tom4i
tom4i / charstack.cpp
Last active July 17, 2016 14:57
CharStack
/*
* File: charstack.cpp
* ---------------------
* This file implements the CharStack class using a Vector<char> as the
* underlying representation. The Vector class already implements most of
* the essential operations for the CharStack class, which can simply
* forward the request on to the underlying structure. The methods are
* short enough to require no detailed documentation.
*/