double

Sorting double values in JTable

▼魔方 西西 提交于 2019-12-10 13:29:47
问题 I have found quite a few questions related to this but I haven't found a simple solution to my issue though. I can't find a way to make my JTable sort Double values properly. I extended AbstractTableModel to receive a Class array and return the proper types per column: class TableModelMod extends AbstractTableModel{ private ArrayList data; private String [] headers; private Class [] types; TableModelMod(String [] heads, ArrayList datas, Class [] classes){ headers = heads; data = datas; types

Java: what's the difference between the sv and sv_SE locale?

社会主义新天地 提交于 2019-12-10 13:22:44
问题 I tried to parse a string (-0,3) to a double in java using Swedish locale using this code: String DoubleString = "-0,3" NumberFormat swedishNumberFormat = NumberFormat.getInstance(new Locale("sv")); System.out.println(swedishNumberFormat.parse(doubleString).doubleValue()); When I tried with the sv_SE locale the result was -3.0, which, obviously, is incorrect. I then, after a lot of headache changed the locale to sv (as in the example above) and then the result was correct, -0,3. According to

C# float infinite loop

痴心易碎 提交于 2019-12-10 12:31:05
问题 The following code in C# (.Net 3.5 SP1) is an infinite loop on my machine: for (float i = 0; i < float.MaxValue; i++) ; It reached the number 16777216.0 and 16777216.0 + 1 is evaluates to 16777216.0. Yet at this point: i + 1 != i. This is some craziness. I realize there is some inaccuracy in how floating point numbers are stored. And I've read that whole numbers greater 2^24 than cannot be properly stored as a float. Still the code above, should be valid in C# even if the number cannot be

Getting the sum of an array of doubles in swift

烈酒焚心 提交于 2019-12-10 12:18:49
问题 I have an array of string numbers that I am fetching from core data and converting to doubles. I would like to get their sum once I've done this, but I get an error. I've tried it like this: override func viewDidLoad() { super.viewDidLoad() //CoreData let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate let managedContext : NSManagedObjectContext = appDelegate.managedObjectContext! var fetchRequest = NSFetchRequest(entityName: "Log") fetchRequest.returnsObjectsAsFaults

casting between short,int,long,double,float in Java

好久不见. 提交于 2019-12-10 12:15:47
问题 As i understand, when you cast between 2 of these types with an arithmetic operation in Java, for example double + int, the result will be as the bigger type (meaning in this example, the result will be double). What happens when you make an arithmetic operation on 2 types with the same size? what will int + float and long + double give? since int and float are 4 bytes each, and long and double are 8 bytes. 回答1: This is all specified by the binary numeric promotion rules in the JLS. From http

Understanding DBL_MAX

谁说胖子不能爱 提交于 2019-12-10 11:41:47
问题 I just read about the IEEE 754 standard in order to understand how single-precision and double-precision floating points are implemented. So I wrote this to check my understanding: #include <stdio.h> #include <float.h> int main() { double foo = 9007199254740992; // 2^53 double bar = 9007199254740993; // 2^53 + 1 printf("%d\n\n", sizeof(double)); // Outputs 8. Good printf("%f\n\n", foo); // 9007199254740992.000000. Ok printf("%f\n", bar); // 9007199254740992.000000. Ok because Mantissa is 52

Sending empty values with PDO results in error

北慕城南 提交于 2019-12-10 11:09:38
问题 We have something like the following PDO Statement which we use to communicate with a PostgreSQL 8.4 DB. $st = $db -> prepare("INSERT INTO Saba.Betriebskosten (personalkosten) VALUES(:kd_personalkosten)"); $st -> bindParam(':kd_personalkosten', $val['kd_personalkosten']); $val['kd_personalkosten'] is either empty/null or contains a double value. In the case it is empty/null, we just want to insert an empty value, but we receive the following error: SQLSTATE[22P02]: Invalid text representation

Conversion Char to double

本秂侑毒 提交于 2019-12-10 11:07:54
问题 How may I convert a numerical value in the form of a char to a double value? I've tried just casting the char to a double but... it doesn't work like that I'm guessing as char such as '4' will convert to 52.0 in doubles. So is there a way to convert a char with a value of say char c = '4' to a double value of 4.0 where I can actually perform mathematical calculations on the value? This is just a little program I created to show that casting a numeric char directly to a double won't work the

BigDecimal Method returns vague results, why does this happen?

ぐ巨炮叔叔 提交于 2019-12-10 10:54:19
问题 Code: package tk.vivekpatani.www; import java.math.BigDecimal; import java.util.Scanner; public class SimpleCalc { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); try{ System.out.println("Welcome to the Calculator!"); System.out.println("Enter Number 1:"); double num1 = sc.nextDouble(); System.out.println("Enter Number 2:"); double num2 = sc.nextDouble(); BigDecimal bd1 = new BigDecimal(num1); BigDecimal bd2 = new BigDecimal

MySql Data truncated for column 'advance' at row 1

☆樱花仙子☆ 提交于 2019-12-10 10:39:37
问题 In my project I used txtAdvance 's key event. double gtotal = Double.parseDouble(txtGtotal.getText()); double ad = Double.parseDouble(txtAdvance.getText()); double due = gtotal - ad; txtDue.setText(String.valueOf(due)); And after last line run, I add a save button to save those data. Given below is that query. public void saveInvoice(JTextField txtgtotal, JTextField txtAdvance, JTextField txtDue, JTextField txtInID) { try { db.putData("INSERT INTO indetails(inid, gtotal, advance, due) VALUES(