---
title: "一个java精度问题1/5 与 (double)1/5 区别"
author: "sooxin"
date: "2019-11-21T22:08:18Z"
tags: []
categories: ["研发管理"]
slug: "java-1-5-double-1-5"
draft: false
lastmod: "2019-11-21T22:08:18Z"
id: 2510229
url: "https://sooxin.iteye.com/blog/2510229"
---

for (int i = 0; i < 1000; i++) {
  double randow = Math.random();
  System.out.println(randow);
  System.out.println((double)1/5);
  if(randow<((double)1/5)){
    System.out.println("true");
  }			
}

System.out.println(1/5);  == 0
System.out.println((double)1/5); == 0.2