3:00 PM
@Mat'sMug you do know that modulo doesn't work on floating point by implication?

how come? doesn't 3.5/2.1 have a remainder?

0

I've written a simple subscriber event system taking advantage of std::function. It works great! (and I can do some big enhancements later with thread-pooling for expensive callbacks) The next step to improve this is to handle events/callbacks with more than one parameter. Other than forcing s...

@Mat no...
A remainder only exists for integer divisions.

@Mat'sMug 3.5 % 2.1 == 1.4 I would say.
Wolfram Alpha seems to agree with me.

@Vogel612 hmm... wth?

3:07 PM
Seems like modulo is even defined for complex numbers: mathworld.wolfram.com/ComplexModulus.html
And as rational numbers is a subset of complex numbers, I see no reason for why it would not be defined for rational numbers as well

How do you handle 0 denominators? I'm not familiar with C# and didn't see anywhere that this was handled. — nhgrif 2 hours ago
I'm hitting a funny problem with this.

@Mat'sMug Throw exception?

@Mat'sMug In a condition before you even try to do the mod

@Mat'sMug Constructor?

3:12 PM
a struct always has a default constructor, which makes 0/0 the default(Fraction)
actually default(int)/default(int)

DID YOU MAKE ME GIVE C ADVICE?!
6

C#, technically.

79

EDIT: I've edited the answer below due to Grauenwolf's insight into the CLR. The CLR allows value types to have parameterless constructors, but C# doesn't. I believe this is because it would introduce an expectation that the constructor would be called when it wouldn't. For instance, consider th...

yeah, C#

Speaking of constructors in C#. Can anyone explain to me why I would want to use a static constructor? I've been reading, but I don't understand the advice I was given.

you don't use a static constructor.
if you have static fields to initialize, might as well initialize them inline
private static int _someInt = 42;

3:18 PM
I don't have any static fields. (At least none that I think should be static.)
3

A Dictionary is the wrong data structure to use for memoization here. An ArrayList would be more appropriate. The reason is that the entries are not independent, but rather sequential: it will remember all entries from the 0th to some maximum. There's not much point to hashing when a simple ar...

Still a C# n00b...

a static constructor would be executed the first time a class is referenced/used

Right. So what's the benefit?

0
(IMO)
or there's something I missed.

Ok. Thanks Mat'sMug. I asked him to clarify, so hopefully he can explain why.

probably means this:
private static Dictionary<int, BigInteger> dictionary = new Dictionary<int, BigInteger>();
which is equivalent to initializing it in a static constructor
(he's right about the Dictionary, but as @svick noted ArrayList is way outdated)
ugh.

3:26 PM
At the risk of sounding really stupid, what's the difference between that and how I did it?

being non-static means each instance has its copy - being static means the type owns it, meaning all instances share the same static data
(hence VB calling it "shared")
hey @rolfl

Ohhh. Ok. So if my main program created a new Fibonacci, it wouldn't have to recalculate the values. Ok.

not sure what "priming the cache" actually means though

Hiya! So I'm about to ask for review for a FizzBuzz implementation in Ruby, anything I should know about?

n == 0 and n == 1 are special cases that can't be correctly calculated by the algorithm. So, I have to "prime" the cache like I'd prime an old motor with gas.

3:33 PM
From what I've seen it's pretty much paste your code and let others tear it apart ;)

More or less @Undo. So long as it's your code and it works.

Okay, great. goes off to post

Welcome to 2nd Monitor btw.

Code only is such a thingy...

@ckuhn203 thanks ;)

3:36 PM
Can't star withou precedessor @ckuhn203

@ckuhn203 Now you tempted me to also do fibonacci with memoization

HAT TRICK
ALL THE PINGS
lol

Does a struct in C# mean that the components are stored directly on the heap, rather than a reference to an object?

Ya know @skiwi. It all started with a recursive implementation. It took me 5 minutes to write that. Now I've spent a month of free time working on that Fibonacci class...

0

I have this implementation of the FizzBuzz challenge in Ruby: (1..100).each do |n| i_3=(n%3==0) i_5=(n%5==0) case when i_3&&i_5 puts 'fizzbuzz' when i_3 puts 'fizz' when i_5 puts 'buzz' else puts n en...

3:41 PM
@Undo Is there anyting against using a few extra blanks in Ruby? I've never coded in it

I'm glad you wrote it @Undo. I thought about doing one in Ruby when I saw there wasn't one.

@undo s/too/to/.
(still in the 5-minute edit window).

2

I have this implementation of the FizzBuzz challenge in Ruby: (1..100).each do |n| i_3=(n%3==0) i_5=(n%5==0) case when i_3&&i_5 puts 'fizzbuzz' when i_3 puts 'fizz' when i_5 puts 'buzz' else puts n en...

@rolfl done

@undo - did you need the lang-ruby ? I don't see it in the list of syntax for the tag, and the tag is set as lang-rb.
is there something I am missing?

3:48 PM
Oh, likely not.
@skiwi ruby is fairly forgiving on the whitespace, unlike Python and friends. I don't think it even needs indentation, really.

OK, and, welcome to Code Review (I know you've been a member for a while, but now you have your first post!)

Yay :D
So... Is there anything against posting like everything you write here?

@skiwi my understanding is as such, struct being a value type.

@Undo Nothing at all.

I think my graphic design question went hot:
4

I am looking for a review for a logo that is going to be shipped with a project of mine. I wanted to keep it simple and clean, with a high level of appeal so that no one will really dislike the design of it. Specifically: Should I implement more color into the design? Is the hexagon a suitabl...

3:52 PM
Hmmm. This might be my new favorite site.
6

Well, it has to work....
Here's an example of a person posting their learning curve: codereview.stackexchange.com/users/28539/…
2

BTW welcome to The 2nd Monitor, @Undo!

@Undo I see, though you could use some in my opinion
@Mat'sMug Ah okay, the thing Java will hopefully have in 3,5 years.

@kleinfreund Have you seen this question yet? I thought you could maybe give some insight: graphicdesign.stackexchange.com/q/35784/27138

@skiwi lol

3:55 PM
@Mat'sMug Sounds a long way off eh

@Undo Your (new?) avatar through me off. I thought I recognized you.

@syb0rg it's fairly new, yeah.

@syb0rg Now I did. ;)
I like the idea of the logo. If you don't want to drop the hexagon, I probably would give the circle more space from it. Also the electron is relatively small compared to the stroke of the circle.

wtf, I forgot how to implement fibonacci with memoization, feeling a bit stupid now

Make it bigger or the stroke thinner.

3:59 PM
@kleinfreund Put it in an answer silly. You should get rep for this.

Oh, my brain started working again

And lots of other people agree on dropping the hexagon.

Ah, come on. I don't have an account there yet and @200 answered what I said yesterday as well. ;)
Another thing—for when the hexagon stays: Rotate it another 15°.

@kleinfreund Ehh, I'll probably get rid of it.

It stands on a tip and is not standing still.
KISS applies for logo design as well.

4:02 PM
Ohh, someone starred my question!

2

Star-ception!

However I signed up there to upvote your question.^^

(@Malachi might have an aneurysm)
This answer has an interesting idea, though it might be a bit too complex.

Okay, do folks usually get multiple answers (and thus hold off on the green check mark), or is one generally what a question gets?

4:07 PM
I agree. You and the participiants of the question would be the only ones knowing all these connections.

The program was originally built to be code golf, and thus the odd variable names. But I've still learnt something today, thanks! — Undo 1 min ago

(very satisfied by the answer, but don't want to discourage other answerers)

@Undo You can just wait a bit.

@Undo I usually hold off for a day or two.

The check mark doesn't run away.
3
And sometimes there comes a better answer.

4:08 PM
Wait for it. I'm not great in Ruby. I might have missed a more idiomatic way to do it.

Yup, thanks.

@syb0rg Also keep in mind that the whole graphic design/logo design thing isn't my main department either. My own logo on my site isn't that great as well.

Why not "print Fizz if %3", "print Buzz if %5", "print space/newline"?

@Undo, mind if I ask what you learned? You didn't say.

@Undo Usually more people will chime in, good reviews do take a while.
@kleinfreund You still have more experience then me ;)

4:10 PM
@MadaraUchiha Some people believe concatenation to be a misinterpretation of the requirements.
(I'm one of them.)

I have to say, I really like the badges over there. Neat. :)

I wonder what the CR badges will look like after we graduate

@kleinfreund Yeah, the SE graphics team had to go all out for them.

@Undo - other people, like me, say the requirements are to print Fizz, Buzz, and FizzBuzz, and I don't care how you get there, but printing fizz, buzz, and fizzbuzz shows a lapse in attention to details ... ;-)

@Mat'sMug I would guess similar to SO

4:12 PM
Hehe, true.

2 stars!

@ckuhn203 mostly that it's a bad idea to put everything inline.

Ahh. Yeah. Separation of concerns.

Well, when I can get away from my SR duties, I'll likely be spending more time here. For whatever reason I want to write an answer.

@undo - There are zombies to kill.

4:14 PM
@Undo We need more Objective-C reviewers, something you seem proficient in.

I was about to suggest that too

Yup, I'll add a few favorite tags.
Ever get any Swift questions?

Unfortunately, about objective-c, @nhgrif has just gone on a massive zombie-killing spree, and has left all questions answered
Yes, we do.
@syb0rg - just posted one.

7

Inspired by this question: Fraction (rational number) structure with custom operators, I have written this class for doing some simple work with fractions. Fraction.h: #import <Foundation/Foundation.h> @interface Fraction : NSObject @property int numerator, denominator; -(void) print; -(void...

Still a small amount of time before I accept an answer
@Undo @nhgrif Has been asking some of those recently. I have been reviewing them however I can.
7

First, the struct itself: struct Fraction { var numerator: Int var denominator: Int { didSet (oldDenominator) { if self.denominator == 0 { self.denominator = oldDenominator } } } init() { self.init(numerator: 0, denominator: 1) } ...

@syb0rg I might take a stab at that one later - might be tomorrow, though.

4:18 PM
@Undo I'm in no rush to accept ;)

Not all of the ObjC questions are unanswered.
8

So, whether you're still in the development stages or your app is already on the app store, you always hope your app isn't crashing. But if it is, you want to be sure you've got good crash reports, right? Moreover, if your app is on the appstore, it may not be sufficient to wait around for Appl...

Gtg folks, cya later.

@Undo - on Code Review, voting tends to work quite well, with good answers bubbling up. A

Oh wait, forgot I did post an answer on there.

FGITW happens, but the good normally wins out
There's always something else to improve... ;-)
4

4:22 PM
0

For below query, +++++++++ If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the function whose value at x is f(f(...(f(x))...)). For example, if f adds 1 to its argument, then the nth repeated application of f a...

4:34 PM
should 1/2 and 2/4 have the same hash code / be equal?
(I think I'm overthinking this)

What's hash code exactly?

Fraction's

They should certainly respond true to an isEqual operation

and basic equality rules say if Equals returns true, GetHashCode should return the same value
so returning ToDecimal().GetHashCode() is ok

hmm...

4:38 PM
this Fraction thing is much more fun than I had anticipated

Yeah.
Fraction class is what first made OOP click for me.

Thing is, I don't want it to be a class, I really want it to be a ValueType
I'm introducing an IsUndefined property to handle the 0 denominator

Yeah. I'm rewriting syb0rg's as a class.
I'm just returning NAN anywhere it might need to if denominator is 0.

that's not crazy at all
except I'm having it as decimal.. and NaN is a float...
ugh
was decimal the wrong choice?

In Objective-C, NAN is a #defined macro.

4:45 PM
@nhgrif Though NAN doesn't necessarily == NAN.
At least, not in C.

    public float ToFloat()
{
return IsUndefined ? float.NaN
: (float)_numerator / (float)_denominator;
}
I can just do ToFloat().Equals(other)
and let C# determine if NaN == NaN
hmm.. a struct can be partial... which means I could implement the operators in a separate code file, and avoid organizing my code with #region :)
there will be a follow-up question, whatever happens to my Fraction review

@kleinfreund How can I get the button to display text equivalent to the OS that the machine is running, such as here?

That'll involve some kind of browser sniffing, but I don't know anything about it.
When someone is accessing a website, things like Browser and OS are visible.
JavaScript probably.

0

I'm new to Ruby and trying to learn Best practices and writing clean code. As a first exercise I have decided to make a Trivia Game and have ended up with two versions: One is with few, but more loaded methods: https://github.com/backslashed/TriviaGame/blob/6b6f697a2adbe144bb0ab0e4d9306d001f2b87...

@kleinfreund Cool stuff.

4:59 PM
@Mat'sMug Is there a reason to store 2/4 as 2/4?
btw, why would you recommend others to fork your own project? Isn't it better to recommend contribution / pull requests?

@skiwi uh, Principle of Least Surprise: if I create a new Fraction(2,4) and then call ToString(), I expect it to print 2/4, not 1/2
no?

There is surely some sense in it
I think though that it would be justified to return 1/2
Because they are the same

that's right.
hmm

And any program relying on your ToString and calculating upon that should die anyway.

lol it's just semantics: ToString should return a string representation of the fraction, I'd expect it to be represented unsimplified, as it was created.

5:02 PM
0

Inspired by this question: Fraction class implemented in Objective-C, I have written what I feel is an improved version of the Fraction class in Objective-C. As per the tips in this answer, the class is immutable (and a mutable subclass might eventually happen). Besides improving on the existin...

ToString is only for some kind of human representation I'd say

1

Inspired by this question: Fraction class implemented in Objective-C, I have written what I feel is an improved version of the Fraction class in Objective-C. As per the tips in this answer, the class is immutable (and a mutable subclass might eventually happen). Besides improving on the existin...

:)

I think I've found my question!

Do you store things in a Store, or do you add things to a Store?

5:09 PM
no clue

I've been looking forward to re-writing this. :-)

@Jamal which?

5

I am studying for a degree in "Bachelor of Engineering in Information and Communication Technologies." I am currently on vacation, just after we started learning C++ at the end of the semester. I wanted to be ahead of the next semester, so I decided to try to use these classes and to make a text...

nice!

I liked this guys take on my logo:
1

It's interesting, but (I assume) It's really the three dots that is the tie into 'TRItium'. As such, I'd consider dumping both the circle and the hexagon. They seem superfluous to the concept. They are nice, but (and this is just my opinion) in the world of software, those tend to give off a bit...

5:13 PM
Does this make sense?
public interface MemoizationStore<T> {

boolean containsOnIndex(int index);

T get(int index);
}

The only problem may be utilizing inheritance. If I cannot, then I may just have to stick to friend. But that list of getters and setters will have to go.

@syb0rg this effectively creates the movement I was after, yesterday ;)
looks really nice

Talk about writing hard to understand code in java.util.Map...
default V getOrDefault(Object key, V defaultValue) {
V v;
return (((v = get(key)) != null) || containsKey(key))
? v
: defaultValue;
}

Hello @BenVlodgi

So if get(key) != null or containsKey(key), then it returns the value
If a SequentialMemoizationStore<T> is one class, how do I call the non sequential variant, any clues?

5:24 PM
0

Here, is an article on password hashing, along with an implementation. Is this code secure with number of iterations 10000, key length 256 and salt bytes 32? Are there vulnerabilities or incorrectly implemented sections in this code? Related questions (1) through (5) are inline. import java...

5:36 PM
Does CR not have anything along the lines of ?

0

I went ahead and I implemented a method to calculate Fibonacci numbers using memoization. public class MemoizedFibonacci { private static final List<BigInteger> FIBONACCI_LIST = new ArrayList<>(); static { FIBONACCI_LIST.add(BigInteger.ZERO); FIBONACCI_LIST.add(BigInteger...

@CaptainObvious You're fast!

0

I'm trying to enhance the execution speed of my below code. I am using only vanilla javascript. I would be willing to bring in additional libraries and plugins as long as they will enhance the overall speed of the code. The goal is to have the absolute fastest execution time of the below code. ...

0

I am trying to get a green rectangle to fire at the apposing sprite and defeat it when it hits. As far as i'm concerned the rectangle should be created when I click space and fired at move.ip[5, 0] speed but I can not see the rectangle. What is wrong with my code and why can't i see the rectangle...

I feel that my answer here (and the other answer, and the question) have received very little attention:
0

Besides the comments you've already received, I'm adding some more: Many of your variables can be marked as private final. All of them can be marked private and those who get initialized directly and never change should also be marked final. These include: Game g = new Game(); Scanner s = new...

You've earned the "Steward" badge (Completed at least 1,000 review tasks. This badge is awarded once per review type) for reviewing "Suggested Edits". (Stack Overflow)
4

5:58 PM
This drives me insane:
1

Installed node.js v0.10.29 which ships with npm v1.4.14 Updating npm to v1.4.20: npm install npm -g (successfully) Checking version: npm -v (still v1.4.14) Although the new version of npm is installed to %AppData\npm\node_modules, the CLI recognizes the one that's being shipped with note (C:\P...

I'm running into one issue after another on Windows.

6:08 PM
ah, now a new Fraction() is represented with ToString() by "0/0" with the default FractionFormatter, and the MathJaxFormatter works as well.
and 0/0 == 42/0
because apparently float.NaN == float.NaN
Is is too early to post a self-review? I have plenty of notes here!

I've reworded the question above for the third time now. Am I really the only one with this kind of problem? :(

0

I tried to look up and suck in most of the information about optimizing this operation and this is what I came up with. As it's pretty much core of the game, I really would like to have it performant as much as I can. I would appreciate if someone can take a look at this and possibly find weak sp...

wow, I managed to get this to work as expected!
Console.WriteLine("{0:p5}", new Fraction(28, 42));
(outputs 66.66667%)
this first time fiddling with custome formatters in C# is pretty fun

Code Reviewers taking over Graphic Design: graphicdesign.stackexchange.com/…

0

I found a nice lightbox2-fork, which I tried to improve. After about six hours of work the code passes jslint. I also tried to change variable names for better understandig of what they are for. What else can be improved there? Also, I'd like to change one behaviour of this script: Images ar...

6:23 PM
@syb0rg Good to see logo making a comeback!

Almost 400 views!

this looks a bit like what I had in mind, except I'd have the circles in different sizes
1

Okay others have good points, I would like to add a new one. The logo is size challenged in that the details are a bit too small. This may be a problem if you need to: work in small scales such as 24 x 24 pixel icons (or even smaller) Print a business card sized medium, you would now need the r...

without the ellipse/electron it just looks like 3 bubbles

@Mat'sMug It'll need some modification if I use it, but I like that it looks more atomic-y

oh nice, string.Format("{0:p3}, new Fraction()) outputs 0.000% :)

6:28 PM
@syb0rg what did you do?

6

I am looking for a review for a logo that is going to be shipped with a project of mine. I wanted to keep it simple and clean, with a high level of appeal so that no one will really dislike the design of it. Specifically: Should I implement more color into the design? Is the hexagon a suitabl...

@Mat'sMug p3? What kind of sorcery percentage magic is that?

I voted on it

Thanks

 public class FractionFormatter : IFormatProvider, ICustomFormatter
{
private static readonly CultureInfo _culture = typeof(FractionFormatter).Assembly.GetName().CultureInfo;

public object GetFormat(Type formatType)
{
return (formatType == typeof(ICustomFormatter)) ? this : null;
}

public string Format(string format, object arg, IFormatProvider formatProvider)
{
var fraction = (Fraction)arg;

6:30 PM
@Mat'sMug But should it be 0% or 100%?

Heya @Malachi

Hey

@skiwi it's whatever .net treats float.NaN as, so it's consistent with the framework ;)

Just checking in, will catch you all later

@SimonAndréForsberg string.Format allows you to specify a... format - "p3" is "percentage with 3 decimals"
it's handled by this line
return string.Format("{0:" + format + "}", fraction.ToFloat());

6:33 PM
I'm afraid you are off here @rolfl
The stream used in Main.main here has nothing to do with my MemoizedFibonacci class, even though I might have implied that. It was simply a way to print the output. If all I wanted was iterative generation, then I would've done it like in my older question. — skiwi 17 secs ago

cyah @Malachi

Maybe I should rewrite the question to make that clear

@Mat'sMug Apparently possible in Java too: stackoverflow.com/questions/698261/…

Browsing to the API in a browser: XML response. Getting the data using HttpClient: JSON response
wat

@rolfl If you're here, I'd like to discuss my question quickly
@JeroenVannevel What? is that

6:40 PM
@skiwi An expression of dumbfoundedness

@JeroenVannevel I more meant what you typed above the wat :)

oh
Well, if you browse to here: moviepicker.azurewebsites.net/api/genres
You'll find an XML response
but when I do var data = _client.GetStringAsync("http://moviepicker.azurewebsites.net/api/genres").Result‌​;, I get that in JSON format

0

Sorry for my English Here is the code: public class FirstActivity extends Activity { private String userName; private Uri userPhoto; private void onOkButtonPressed() { Intent intent = new Intent(this, SecondActivity.class); intent.putExtra(SecondActivity.Key.USER_N...

@JeroenVannevel wat
Okay..

Oh well, maybe it fixes itself after a shower and the finals
I believe

6:46 PM
@skiwi I am here ;-)

@rolfl It may be better if I just leave out the whole main.Main from that question as it's actually irrelevant, but I'd need your call on that as it would invalidate your answer partly

partly, but the rest of my answer (updated) makes sense with, or without the main.

Most of it still makes sense
May I edit it out of my question?

Also, the way you are using the List, is not really memoization, but caching.
@skiwi Sure.
@skiwi - you should remove the tag as well then.

(That is why I tried to catch you before you edited yours)
Done and done
What is the difference of memoization vs caching then?
I thought caching was a fixed-size memory that can get full and may discard old entries, while memoization stores everything always.

6:49 PM
Well, memoization is typically part of a long running algorithm where the next iteration can depend on previously calculated values.
In your case though, you can call your method multiple times, and it saves the state of previous runs of the system, not just the current run
If the input number is smaller than a previously calculated number, it does nothing.

So memoization is a trick used in one run of an algorithm, where caching is between runs
btw. I refactored that check to isInFibonacciList because it feels more logical to me, that whole equation of number <= FIBONACCI_LIST.size() - 1 resp number < FIBONACCI_LIST.size() is a little bit hard to grasp for me currently

Should be easy enough, number is an index in your arraylist, right?
it is valid if number < size()
The relationship that number is the index is more obvious if you do:

if (number < FIBONACCI_LIST.size()) {
return FIBONACCI_LIST.get(number);

0

I want to loop through resultset using Jquery and display in html. here is my code var message = result.invocationResult.resultSet; for(var index=0; index<message.length;index++){ document.getElementById("demo1").innerHTML = message[0].FirstName; document.getElementById("demo11").in...

6:56 PM
@rolfl Is the number < FIBONACCI_LIST.get(number) intended there? (The retrieval of element from list)

^^^ was just a copy/paste problem, let me fix.

Now it makes more sense :)
World cup starts now though

0

The question is here. 100 people are standing in a circle with gun in their hands. 1 kills 2, 3 kills 4, 5 kills 6 and so on till we are left with only one person. Who will be the last person alive. Write code to implement this efficiently. Here is my Java implementation: public static voi...

0

Code correctness, best practices, design and code formatting review if you please. =] (C++11) I will be adding functionality and most likely additional refactoring, however a stringent review would be welcome before I build it further. I know documentation is probably a bit sparse but, you know ...

7:32 PM
watch the next newsletter be covered with questions!
3

Hopefully I'll be done with my question soon. Luckily the OP of the original question didn't make the game too complicated (just messy).

Enter a fraction:
.725
29/40 (0.725)

7:49 PM
@Mat'sMug Fractinating!
2
I have a rough idea for an application I want to make, but I'm struggling with how to actually implement it, any clue if a description of my problem and an outline of my intentions would be a fit on programmers.SE?

@CaptainObvious Don't post interesting questions during a world cup final!
0

One thing that I find is that it is not necessary to wrap your keys inside their own inner class. Putting them inside SecondActivity directly is enough. public class SecondActivity extends Activity { public static class Key { public static final String USER_NAME = "USER_NAME"; ...

needs a vote here:
2

public class FirstActivity extends Activity { private String userName; private Uri userPhoto; private void onOkButtonPressed() { Intent intent = new Intent(this, SecondActivity.class); intent.putExtra(SecondActivity.Key.USER_NAME, userName); intent.putExtra(S...

Fraction1: 2/1 (decimal: 2)
Fraction2: 2/4 (decimal: 0.5)
2/1 + 2/4 = 5/2 (decimal: 2.5)
2/1 - 2/4 = 3/2 (decimal: 1.5)
2/1 * 2/4 = 1/1 (decimal: 1)
2/1 / 2/4 = 4/1 (decimal: 4)
Fraction3: $\frac{2}{1}$ (2/1)
Fraction4: $\frac{2}{4}$ (2/4)
Fraction5: \$\dfrac{2}{1}\$
Fraction6: \$\dfrac{2}{4}\$
3/4
6/8
1/6
21/3
21/3
8.666667
0/0 == 42/0: True
21/1 == 42/2: True
(0.000 %).CompareTo(1) = -1
Enter a fraction:
725/1000
29/40 (0.725)

@Mat'sMug Nice

@skiwi thanks! I was missing == and != operators, and Parse+TryParse methods, and so many other things!
it's getting pretty nice now

You are tempting me to make one as well
but Java really needs value types for that to work well
well, to perform well

7:56 PM
hehe

I'm hoping a specific Valhalla build comes up in time, preferably within a year, I'd use it to play around, Valhalla is supposed to include value types and generics with value types (which also includes primitives thus)

8:10 PM
Console.WriteLine(Fraction.Empty == "0/1"); prints true :)
I think I'll post a selfie

8:36 PM
should I enable things like Console.WriteLine(new Fraction(13,52) + "1/4") (would output 1/2)? How much operator overload is too much operator overload?
"if an operator can throw a FormatException, it's not a good operator" - would that make a good rule of thumb?

8:57 PM
@syb0rg Cancel my taking a stab at it - someone else already got all the things that I was going to say (particularly the superflousness of the get/setters in the implementation)

9:14 PM
fraction++ works, too :)
@SimonAndréForsberg now I feel like I've implemented my Fraction type à la Simon André Forsberg!

Uh question: Why haven't you folks graduated yet?
18

@Undo very good question
we need more voters and returning customers

22.3K visits/day, too! =)

Yes, mostly voting and user-retention. We do have enough 2K/3K/10K/20K, at least compared to other sites.

9:22 PM
is this a good idea?
    public Fraction(float value)
: this(Fraction.Parse(value.ToString()))
{
}

9:35 PM
0

I am actually pretty damn proud of this code, it's my first complex algorithm I have made. Basically it sets a shapes default size and radius based on how many characters are in a string that is passed to it, the user gets the option to manually set the Font, otherwise it is automatically set for...

9:45 PM
Well that was a good game :)

Indeed, @Simon

@Mat'sMug In Java, all operator overload is too much (except for + for strings) because it's just not possible :)
@kleinfreund SPOILER ALERT: (removed) (see edit for the spoiler)

Congratulations to the teams. It was a great game.

It felt a bit rough at times, but oh well...
@Mat'sMug Can it solve a Samurai Sudoku!? :)

Yes, it was very rough. I don't like that part about it at all. :/

9:50 PM
@Mat'sMug just kidding, I would love to --see it--- review it
@kleinfreund Me neither
@Mat'sMug Doesn't feel like a good idea to me.

But man, what a game.

Indeed
@Svante Indeed I am Swedish. Come and say Hej to me and the other (non-Swedish) site regulars in The 2nd Monitor chatroom :) — Simon André Forsberg 9 secs ago
3

Besides the comments you've already received, I'm adding some more: Many of your variables can be marked as private final. All of them can be marked private and those who get initialized directly and never change should also be marked final. These include: Game g = new Game(); Scanner s = new...

@Mat'sMug 1555 to target