Skip to content

Commit 77b06c4

Browse files
hansonrhansonr
authored andcommitted
Math.floorDiv(long,long)
1 parent 2beb456 commit 77b06c4

File tree

9 files changed

+59
-5
lines changed

9 files changed

+59
-5
lines changed
2 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20210101091131
1+
20210101115709
2 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20210101091131
1+
20210101115709
2 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/test/JavaFiddle.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,39 @@ public class JavaFiddle extends javax.swing.JFrame implements java.awt.dnd.DropT
44

55
java.awt.dnd.DropTarget target;
66

7+
public class ThreadTest {
8+
9+
public String delayedReturn(String s) {
10+
11+
try {
12+
Thread.sleep(5000);
13+
} catch (InterruptedException e) {
14+
return e.getMessage();
15+
}
16+
return s;
17+
18+
}
19+
}
20+
21+
private javax.swing.JButton newTestButton() {
22+
javax.swing.JButton b = new javax.swing.JButton("testing");
23+
b.addActionListener(new java.awt.event.ActionListener() {
24+
25+
@Override
26+
public void actionPerformed(java.awt.event.ActionEvent e) {
27+
javax.swing.JOptionPane.showConfirmDialog(null, new ThreadTest().delayedReturn("OK"));
28+
System.out.println("ok");
29+
}
30+
31+
});
32+
return b;
33+
}
34+
35+
736
public JavaFiddle() {
37+
38+
startFiddleFrame();
39+
840
setSize(new java.awt.Dimension(400,400));
941
//setPreferredSize(new java.awt.Dimension(400,400));
1042
setTransferHandler(new javax.swing.TransferHandler() {
@@ -50,6 +82,14 @@ public boolean importData(javax.swing.TransferHandler.TransferSupport support) {
5082

5183
}
5284

85+
private void startFiddleFrame() {
86+
87+
javax.swing.JFrame f = new javax.swing.JFrame();
88+
f.setLocation(400, 400);
89+
f.add(newTestButton());
90+
f.pack();
91+
f.setVisible(true);
92+
}
5393
@Override
5494
public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde) {
5595
}

sources/net.sf.j2s.java.core/src/test/Test_Long.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,22 @@ public static void main(String[] args) {
6161

6262
private static void testLongMath(long j, long k, long l) {
6363

64-
// TODO Auto-generated method stub
64+
k = -230842039822340L;
65+
l = 23942392332L;
66+
j = k/l;
67+
assert(j == -9641);
6568

69+
j = Math.floorDiv(k, l);
70+
assert(j == -9642);
71+
72+
73+
l = -12323942392332L;
74+
j = k/l;
75+
assert(j == 18);
76+
77+
j = Math.floorDiv(k, l);
78+
assert(j == 18);
79+
6680
}
6781

6882
private static void testFieldAccess() {

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3455,7 +3455,7 @@ Math.subtractExact$J$J = function(x, y) {
34553455

34563456
Math.floorDiv$J$J = function(x,y) {
34573457
var r = Long.$div(x,y);
3458-
return (r < 0 && Long.$ne(Long.$mul(r,y), x) ? Long.$dec(r) : r);
3458+
return (r < 0 && Long.$ne(Long.$mul(r,y), x) ? Long.$inc(r, -1) : r);
34593459
}
34603460

34613461
Math.floorMod$J$J = function(x,y) { return Long.$sub(x, Long.$mul(Math.floorDiv(x, y), y)); }

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17470,7 +17470,7 @@ Math.subtractExact$J$J = function(x, y) {
1747017470

1747117471
Math.floorDiv$J$J = function(x,y) {
1747217472
var r = Long.$div(x,y);
17473-
return (r < 0 && Long.$ne(Long.$mul(r,y), x) ? Long.$dec(r) : r);
17473+
return (r < 0 && Long.$ne(Long.$mul(r,y), x) ? Long.$inc(r, -1) : r);
1747417474
}
1747517475

1747617476
Math.floorMod$J$J = function(x,y) { return Long.$sub(x, Long.$mul(Math.floorDiv(x, y), y)); }

0 commit comments

Comments
 (0)