|
Notorious QIG posted:guys last week i had to convert from degrees to radians by hand, without using a built-in library function this sounds EXTREMELY BAD!!
|
# ? May 2, 2016 15:35 |
|
|
# ? May 27, 2024 10:28 |
|
BattleMaster posted:the appeal of what you want is limited enough that several people can't think of a reason why it needs to be standard listen bud if i stopped bitching about dumb poo poo on the internet i would probably have nothing left to post about
|
# ? May 2, 2016 15:40 |
|
fair point
|
# ? May 2, 2016 15:42 |
|
actually, imagining that some terrible dragon lurks within the conversion to percentages is the behavior of a good programmer, not a terrible one.
|
# ? May 2, 2016 16:16 |
|
i mean, there's floats in there, it's potentially some kind of weird string and not really a number at all. should you be persisting things as a percentage or as the numerator/denominator? also casting to an int seems incorrect to me in most cases. there's plenty of potential thorniness there.
|
# ? May 2, 2016 16:20 |
|
Captain Foo posted:this sounds EXTREMELY BAD!! *writes M_PI* *spends several years in therapy*
|
# ? May 2, 2016 16:20 |
|
Asymmetrikon posted:no, it's just a really lovely version of the option monad nah, option monad requires you to either attempt evaluations within a context or handle the empty case. this is like really wanting a lang where null swallows all method calls. null object is garbage.
|
# ? May 2, 2016 16:25 |
|
is there some sane reason for why all this javascript i'm looking at is couching all page changes in try-catch blocks (note: the catch part of the block is empty for all of them)?
|
# ? May 2, 2016 16:26 |
|
MALE SHOEGAZE posted:i mean, there's floats in there, it's potentially some kind of weird string and not really a number at all. should you be persisting things as a percentage or as the numerator/denominator? also casting to an int seems incorrect to me in most cases. that's why the correct answer, linked last page and completely ignored, handles at least the cultural issues around it
|
# ? May 2, 2016 16:26 |
|
FamDav posted:nah, option monad requires you to either attempt evaluations within a context or handle the empty case. this is like really wanting a lang where null swallows all method calls. null object is garbage. but you stop getting all those pesky nullpointerexceptions, the bane of a java programmer's existence
|
# ? May 2, 2016 16:29 |
|
https://www.youtube.com/watch?v=bLHL75H_VEM
|
# ? May 2, 2016 16:31 |
|
HoboMan posted:is there some sane reason for why all this javascript i'm looking at is couching all page changes in try-catch blocks (note: the catch part of the block is empty for all of them)? the most likely explanation, is that it was written by a terrible programmer
|
# ? May 2, 2016 16:59 |
|
JawnV6 posted:that's why the correct answer, linked last page and completely ignored, handles at least the cultural issues around it the string format is A Good Solution for presenting a percentage to the user, but for this case i need an int for comparison purposes so i guess im just gonna do a lot of bad and ugly casting
|
# ? May 2, 2016 17:13 |
|
BiohazrD posted:the string format is A Good Solution for presenting a percentage to the user, but for this case i need an int for comparison purposes so i guess im just gonna do a lot of bad and ugly casting what
|
# ? May 2, 2016 17:15 |
|
BiohazrD posted:the string format is A Good Solution for presenting a percentage to the user, but for this case i need an int for comparison purposes so i guess im just gonna do a lot of bad and ugly casting tfw you know someone is doing something wrong and you want to know why, but u know asking will just make more work for u.
|
# ? May 2, 2016 17:17 |
|
the user gets asked for a percentage, so they put in an int. lets say 50. its not like i can ask them to convert it to decimal before they enter it so i convert the user input into a decimal (.5) and compare that to my calculated percentage (<= .5 is a failure state, > .5 is aokay) im not actually going all the way to an int because thats dumb but the situation made me think "huh why isnt there a function to do this so i dont have to look at nasty casts"
|
# ? May 2, 2016 17:28 |
|
BiohazrD posted:the user gets asked for a percentage, so they put in an int. lets say 50. its not like i can ask them to convert it to decimal before they enter it computer, calculate 50% of 100. but if you return exactly 50, throw an error.
|
# ? May 2, 2016 17:32 |
|
anthonypants posted:computer, calculate 50% of 100. but if you return exactly 50, throw an error. what the gently caress are you talking about the calculated percentage is an outside system that is being monitored, that outside system can at any time report the number of discrete data points that it has (Y), and the number of those data points that are determined to be within an acceptable range (X) X/Y = percent if that calculated value falls below the user specified threshold (in this example 50% or .5) then the system should be considered to be in a failure state
|
# ? May 2, 2016 17:38 |
|
so uhh why can't you just do input <= 50
|
# ? May 2, 2016 18:00 |
|
are you complaining that you need to cast the user input string to a number? because that's, like, p common. not sure how it works in c# but in c/c++ you can really easily just scanf or atoi it
|
# ? May 2, 2016 18:05 |
|
BiohazrD posted:X/Y = percent quoting for shame
|
# ? May 2, 2016 18:05 |
|
how do i calculate percentage in jquery?
|
# ? May 2, 2016 18:06 |
|
BiohazrD posted:the user gets asked for a percentage, so they put in an int. lets say 50. its not like i can ask them to convert it to decimal before they enter it theres probably a jquery that masks the percentage value as int for the user w/ a decimal submission value
|
# ? May 2, 2016 18:09 |
|
Wheany posted:how do i calculate percentage in jquery? code:
|
# ? May 2, 2016 18:12 |
|
no joke suddenly I got a realization about why people like javascript by seeing BioHazrD complaining here about converting user input
|
# ? May 2, 2016 18:12 |
|
Lmao this has nothing to do with user input If you want an integer representation of a percentage you have to do a shitload of casts. That's fine because integer division is not decimal division. But when your own common library (such as in backgroundworker) wants a value in this form maybe provide an easy way to do it so you don't get horrible looking code with 20 casts in one line
|
# ? May 2, 2016 18:20 |
|
Like the math library is right there and it does tons of poo poo. Throw a percentage function in there! gently caress
|
# ? May 2, 2016 18:21 |
|
BiohazrD posted:you have to do a shitload of casts
|
# ? May 2, 2016 18:22 |
|
BiohazrD posted:
you don't want this
|
# ? May 2, 2016 18:22 |
|
Shaggar posted:you don't want this Maybe tell microsoft that https://msdn.microsoft.com/en-us/library/ka89zff4(v=vs.110).aspx
|
# ? May 2, 2016 18:24 |
|
BiohazrD posted:Like the math library is right there and it does tons of poo poo. Throw a percentage function in there! gently caress i dont know c# very well so here's a c++ version for you code:
|
# ? May 2, 2016 18:24 |
|
BiohazrD posted:Maybe tell microsoft that this is because the progress bars in some cases use int values for max and current. its not for percentage, but you could certainly just show current as "{0}%"
|
# ? May 2, 2016 18:26 |
|
BiohazrD posted:Maybe tell microsoft that that is a legitimate api gripe but BackgroundWorkers are old news, use tasks and IProgress<T>
|
# ? May 2, 2016 18:28 |
|
Shaggar posted:this is because the progress bars in some cases use int values for max and current. its not for percentage, but you could certainly just show current as "{0}%" the linked doc page literally says "The percentage, from 0 to 100, of the background operation that is complete."
|
# ? May 2, 2016 18:29 |
|
yeah but its intention is for use in progress bars. not a litterral percentage display, tho you could do that too.
|
# ? May 2, 2016 18:30 |
|
Shaggar posted:this is because the progress bars in some cases use int values for max and current. its not for percentage, but you could certainly just show current as "{0}%" nah it explicitly says it's a percentage and doesn't provide any obvious way to specify a max that isn't 100 microsoft made a bad api, it happens sometimes
|
# ? May 2, 2016 18:34 |
|
its percentage complete but its intended for user display in progress bars where the progress bars take a current and max int value for display. that's why the api is done that way.
|
# ? May 2, 2016 18:38 |
|
c enterprise programming s: getting Conway's law'd so hard
|
# ? May 2, 2016 18:40 |
|
but that's a flawed api. if the progress bars take a current and max integer then the api should work with current and max integers, not hardcode the max to be 100.
|
# ? May 2, 2016 18:42 |
|
|
# ? May 27, 2024 10:28 |
im looking at the pile of poo poo ive cobbled up since the last spring and its slowly creeping into my mind that coder's salary is literally is a function of usable their poo poo is
|
|
# ? May 2, 2016 18:57 |