« first day (2895 days earlier)      last day (2045 days later) » 

3:00 PM
Hello
 
if (!hasChangedALineYet && line.startsWith("\t"))
{
    line = line.replace("\t", "    ");
    hasChangedALineYet = true;
}
 
@Lozansky Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
 
I want to generate a random number until it satisfies a condition
 
do-while
 
So, while a condition is not true, do something?
 
3:01 PM
while(this.age-(2018-year)<15){
year = (int)(1934+Math.random()*84);
}
this.year = year;
 
@MadaraUchiha It's a very dated joke from Borat, a 2006 comedy film
 
@Lozansky change to do-while ;)
 
(I'm mostly working in python, and that's how I would do there)
@Wietlol Is that (to do-while) the standard way to do conditional while loops?
 
is Math.random in Java the same as JavaScript?
 
3:04 PM
no
 
hell nah
 
@rlemon Yes
 
@Lozansky not really
 
Returns a double between 0 (inclusive) and 1 (exclusive) docs.oracle.com/javase/8/docs/api/java/lang/Math.html#random--
 
but you want to get the value, then you want to check if that value is correct
I assume you dont really have a starting value for your year field
but what is the issue with it?
also... dont use Math.random()
 
3:07 PM
@Wietlol No, I am randomly generating one in the constructor
Why not?
 
@MadaraUchiha eh. If you use that as argument, you can say that JavaScript does not have a double type >.>
 
there is a better thing for your use case
 
@KarelG No, JavaScript only has a double type.
The only number type that JS has is double.
 
@Wietlol Hmm, program still runs into an infinite loop with do-while
 
the double "type" in javascript is different than that one in Java o.o
 
3:08 PM
@KarelG How?
 
you see two dogs but they aint of same species
 
In what, exactly, do they differ?
 
I think JS Number is fairly equal to Jaba Double
ignoring the Jaba type system that is
 
Heya, Y'all
 
Anyway, I just want to generate a random int until it satisfies a condition
Should be super() simple?
 
3:10 PM
It's the same precision and limitations, just because you have to say 1.0 else it would be an int, or that you call it Double.NaN instead of just NaN doesn't change the fact that they're completely the same.
 
@Lozansky Was that a joke or a question?
 
@Lozansky I suspect that your condition is never satisfied
 
@unknown Both?
 
@Lozansky That has a complexity of O(∞)
 
One of you folks perchance know where / how I can find a supported and maintained version of maven's aether?
 
3:12 PM
@MadaraUchiha Sounds efficient
 
@MadaraUchiha not really
 
it was originally created by sonatype, then moved to eclipse, but was apparently abandoned there in 2016
 
@MadaraUchiha Why?
 
its O(1)
 
Alright, I'm heading home, gnight everyone \o/
 
3:12 PM
@Lozansky because there is an infinite sequence of integers that do not satisfy your condition
 
but it could potentially take forever
 
while (n != 0.5) {
  n = Math.random();
}
This will run forever
 
@Wietlol meh. landau notation is bad at dealing with probabilities
 
@Vogel612 No, because I am not generating any random number, it is in the interval $[1934,2017]$
 
what's the exact condition you want to fulfil?
 
3:13 PM
Also, @Lozansky basic math: a - (b - c) = a - b + c
 
I know
 
only that it's in that range?
 
So your number is basically always growing, thus your supposition that it will ever be smaller than 15 is always false.
 
use random.nextInt(1934,2018);
 
Ah, no, I'm stupid, ignore me.
 
3:14 PM
@Vogel612 I'll try that next. But this should work lol
 
@Lozansky but you can do this without loop really easily
there is no need to attempt making it work with the loop
 
What are you trying to do exactly?
 
@Lozansky bleh. picking at random and rejecting is a really bad strategy instead of using the "select random from interval"
 
also... dont use ints for age and birthday
Java has one of the better time libraries I have seen so far
 
I have a fixed integer $a>15$ and I want to generate a random integer $n\in [1934,2017]$ until $a-(2018-n)>15$
 
3:16 PM
no...
just no ....
 
@Lozansky that is not what you want
you want something else
 
you want a random integer \$n \in [2003 - a , 2002]\$
 
and you think this is an approach to get there
@Data
class Person
{
	private final LocalDate birthDay;

	public int getAge()
	{
		return Period.between(birthDay, LocalDate.now()).getYears();
	}
}
ah
pure satisfaction
 
nice
 
@MadaraUchiha check for minimum value at both platforms (Double.MIN_VALUE and Number.MIN_VALUE
I believe that it is off by one
 
3:21 PM
Does @OakBot have a Java repl?
 
@MadaraUchiha Type /help to see all my commands.
 
/help
 
> My commands are also listed here: github.com/JavaChat/OakBot/wiki/Commands
 
/Double.MIN_VALUE
 
/about
 
3:21 PM
OakBot by Michael | source code | JAR built on: Today at 12:29 AM | started up: Today at 12:30 AM | responded to 9566 commands since Mar 9, 2017
 
I think oak doesnt have
 
boo
lemme fire up a javac
 
Java: 4.9e-324
 
min double in java: 4.9E-324
 
JS: 5e-324
 
3:22 PM
Number.MIN_VALUE: 5e-324
:D
 
:p
 
@Wietlol I can show in Python how this would work
 
@KarelG now try BigDecimal.MIN_VALUE
 
lol...
 
@Lozansky I can show you that in Python, you still dont want that
 
3:23 PM
@Wietlol BigDecimal is different -.-
 
Double.NEGATIVE_INFINITY?
 
I don't think so either.
 
@Vogel612 not really
 
3:23 PM
@KarelG That's within the value of epsilon.
 
Double NegativeInfinity is a special value
 
still different :P
 
@Wietlol What's wrong with this approach?
 
BigDecimal is arbitrarily large
 
@KarelG Because it's platform/implementation dependant...
 
3:24 PM
@Lozansky you obfuscate your goal
 
see. You named the difference
 
your goal isnt to generate random numbers
 
It is
 
your goal is to get a value that satisfies certain rules
 
remember what I said about the dogs and species
 
3:24 PM
@KarelG I wouldn't be surprised that it differs between browsers in JS too...
 
@Lozansky No, it isnt
 
No, it should be a random number AND satisfy a condition
 
@MadaraUchiha that can be said too with Math.randon
 
yes, but not a series of attempts
 
@KarelG No, Math.random() is defined in the specification.
 
3:25 PM
you want one random number out of a range of numbers that satisfy your conditions
 
devs behind the browsers decides which approach to take
lemme continue this tomorrow/ I have to go
 
@Wietlol Yes
 
kk ttyl
 
so, what is your goal?
@MadaraUchiha ttyl?
 
/urban ttyl
 
3:26 PM
@MadaraUchiha ttyl: talk to you later
 
ah
 
@Wietlol Nvm, I know why it didn't work
Error-by-one
 
im happy for you that you found out why it didnt work, but you should still consider rewriting this
like... REALLY consider rewriting this
 
If it works...
 
it doesnt work
it cries until the horror is over
then goes back to work
considering that this is your condition: age - (2018-year) < 15
where age is known and year should be generated
there is a specific range of values that year could be to satisfy that
you should simply take a random number out of that range
you never really want to get a random value out of a collection of valid and invalid values
you want to exclude the invalid values at all cost
 
3:31 PM
Sure, I don't mind changing that
Is there a method to generate a random number from a specific range?
 
Math.random()
for one
 
@Lozansky use random with a seed
 
but you could also make a random number generator
or use the random number generator from the thread
 
Alright, I meant like randint(a,b) like in Python
 
there is not really a need for that
only a limit
not a starting point
 
3:34 PM
3298
A: How to generate random integers within a specific range in Java?

Greg CaseIn Java 1.7 or later, the standard way to do this is as follows: import java.util.concurrent.ThreadLocalRandom; // nextInt is normally exclusive of the top value, // so add 1 to make it inclusive int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1); See the relevant JavaDoc. Thi...

 
except when overflows and underflows come and say hi
 
3:46 PM
@Wietlol
     this.year = 2033-this.age+(int)(Math.random()*(this.age-15));
Hope that isn't too horrible
 
~pukes a little
 
you should still use ThreadLocalRandom
 
:(
 
generating a random double and multiplying is just obfuscation
 
Hey Vogel!
 
3:49 PM
something like ThreadLocalRandom.current().nextInt(1919 + age, 2018);
 
hai @geisterfurz007
 
posted on September 26, 2018 by CommitStrip

 
WOOOT
I got lombok working with Jigsaw
WOOOT
hmm... interop still gives an issue
 
4:40 PM
Currently doing some testing and having a brain fart
Can anyone name a Class that has nested superclasses?
Or I could just create my own I guess
 
Why would you create a nested superclass?
So you have to do SubClass.SuperClass if you want something from it?
That sounds like a violation of some oop concepts for sure.
 
Well, in our case, we got a BoundedCounter, that has a Counter superclass, which technically has a Generic Object-superclass
No?
 
errrrrrrrrrr Not sure.
But my brain is too fried already that I could get myself to think clearly about that, sorry.
 
xD
No worries
 
Zoe
5:28 PM
Damn, my code works owo
@gei @mic Still missing content, but it's really easy to add. The PR: github.com/JavaChat/JavaChat.github.io/pull/1
And there's a bug xd
There we go :3
 
5:59 PM
@Zoe Just relying on you: Does that work?
Or is there a way I can take a look into it how it is right now?
 
Zoe
Missing content, but runs.
@geisterfurz007 I can send some screenshots. Otherwise you'll need to install Ruby
 
Option 1 would be great :)
 
Zoe
 
That is amazing! Thanks for putting the time into it :)
Oh lol! I thought I had write access.
 
Zoe
No problem ^^ Anything you want to add to it can be done with regular markdown files now. It doesn't have blogging, but that's not too hard to add
 
6:09 PM
 
herro
 
Zoe
Hiya
 
whattuuppp
 
Zoe
IT'S STILL A DIRECTION!!! Not much. How 'bout you?
 
Ehhhh just got back from a long old team lunch haha
 
6:31 PM
gross
 
o.O
It was pretty dope actually
nice Italian place with fresh in-house made mozzarella
mmm
 
Zoe
But... other people! :p
 
wait, what?
Ohhhh I see
gross because social interaction
 
^ yes
unneeded social interaction
 
ahhh
I like social interaction
 
6:42 PM
I do as well. Just not too much.
 
I see
Let me rephrase that then, I love social interaction
tbf I'm not really a stereotypical programmer though
 
I don't like forced social interaction
If I wanted to talk to my coworkers, I would
 
Zoe
So don't
lol
No one's forcing you to talk
 
(That was the explanation why Nathvi wouldn't like a team lunch) Looks like you forgot the context again Zoe :P
 
They're forcing me to be there
If I have to look at you, that's social interaction.
 
6:48 PM
Hide on the toilet >.>
 
lol
 
Zoe
@geisterfurz007 There's free food and you can get far with a headset :>
 
I have a headset. Would rather be by myself at home.
I don't think I should have to drown out background noise with background noise
 
Zoe
But when you can't, make the best of it
 
or find a new job
 
Zoe
6:51 PM
That's a really hard way of dealing with it though
 
not if you work remote fully
 
Zoe
if you work remotely, why do you have team lunches?
 
If I did work remote. I don't.
 
Zoe
So why do you bring up non-relevant hypotheticals?
 
Clearly you weren't following. shrug
 
6:57 PM
This conversation seems to move in a direction that is too hard for my tired brain. Have a good night o/
 
Zoe
@Nathvi Nope, because last time I checked this was a real problem we were discussing
 
Yeah wise decision. Bye :D
 
lol
Sounds like you actually don't like social interaction at all @nath
 
Zoe
@geisterfurz007 anything > 6 hours is a wise decision :*
 
oooo
got my credit application for financing a bed
fannnccyy
 
7:29 PM
@Zoe Looks good!
 
Zoe
^^
 
Does it need Ruby to run?
 
Zoe
Yeah, but GitHub pages supports all that. Once it's pulled into master, it'll build, and deploy assuming I didn't screw up anything on the gem versions
 
Oh, nice.
 
Zoe
Jekyll is supported natively. Wouldn't bother using it if it wasn't :D
You can edit any pages on GH for that matter, once the commits go on the master branch, the page is built and published
 
7:35 PM
Don't you have commit permissions?
 
Zoe
Nope
 
I'll see if I can add you when I get home.
 
Zoe
oki
 
7:57 PM
Hi
I have some awful code but I am not sure how to make it better
It works
 
Dax
Hi guys! Could someone please help me with paste.ofcode.org/sTyWfe8dAuM67n2YPshxL5 , my commands at the top of the program says what I am suffering from :D
 
(I am not allowed to use math class)
 
8:15 PM
Looks like my bed is financed and will be showing up on friday
\o/
lmao
 
Zoe
@JBis that won't work for numbers < 10 && > 99
 
@Zoe I tested 4.556,3.668, and 44.9891 and it worked
 
/javadoc String#getBytes
3
 
@Zoe And 104.3381
 
8:20 PM
Your file contains "3,4,1,5"
Files.lines gives a Stream<String> with the String(s) being: ["3,4,1,5"] (ie you only have one String in that Stream)
map([...]) gives a Stream<String[]> with the String[] being: [["3", ",", "4", ",", "1", ",", "5"]] (again one String[] in the Stream)
flatMap gives a Stream<String> with the Strings being: ["3", ",", "4", ",", "1", ",", "5"] (ie all characters in your file)
map([...]) gives a Stream<byte[]> with the byte[] being: [[51], [44], [52], [44], [49], [44], [53]] (ie the byte ARRAY representations of your characters)
 
Zoe
Oh
Nvm then ^^"
 
Where do you find "application.properties" in intellij?
 
Dax
@geisterfurz007 thank you! it takes time till I learn all this , I just keep reading and trying
 
I can only suggest again: Become clear of what every single step does. For debugging and understanding, you can also add a .peek(System.out::println) after each other operation (peek is essentially a forEach that returns the input parameter so you can do any operation on the current Stream item).
 
Dax
Thank you so much
I'll be more careful
 
 
2 hours later…
11:00 PM
🤔
 
@JennaSloan Welcome back!
 
11:26 PM
@Zoe Also: Sent you an invite.
 
11:54 PM
Oh no! Not dependencies!
Completely unrelated:
Official locale data for English: unicode.org/cldr/charts/latest/summary/en.html
 

« first day (2895 days earlier)      last day (2045 days later) »