Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "floating points"
-
iPhones are ridiculously picky when it comes to finding a mate- um charger. And knowing why doesn't really make it any easier to understand why. If anything it baffles me more.
So, let's start with appliances that are not phones. Think Bluetooth headsets, keyboards, earbuds, whatever. Those are simple devices. They see 5V on the VCC line and 0V on ground, and they will charge at whatever current they are meant to. Usually it will not exceed 200mA, and the USB 2.0 spec allows for up to 500mA from any USB outlet. So that's perfectly reasonable to be done without any fuss whatsoever.
Phones on the other hand are smarter.. some might say too smart for their own good. In this case I will only cover Android phones, because while they are smarter than they perhaps should be, they are still reasonable.
So if you connect an Android phone to the same 5V VCC and 0V ground, while leaving the data lines floating, the phone will charge at 500mA. This is exactly to be within USB 2.0 spec, as mentioned earlier. Without the data lines, the phone has no way to tell whether it *can* pull more, without *actually* trying to pull more (potentially frying a charger that's not rated for it). Now in an Android phone you can tell it to pull more, in a fairly straightforward way. You just short the data lines together, and the phone will recognize this as a simple charger that it can pull 1A from. Note that shorting data lines is not a bad thing, we do it all the time. It is just another term for making a connection between 2 points. Android does this right. Also note that shorted data lines cannot be used to send data. They are inherently pulled to the same voltage level, probably 0V but not sure.
And then the iPhones come in, Thinking Different. The iPhones require you to pull the data lines to some very specific voltage levels. And of course it's terribly documented because iSheep just trying to use their Apple original white nugget charger overseas and shit like that. I do not know which voltage levels they are (please let me know!), but it is certainly not a regular short. Now you connect the iPhone to, say, a laptop or something to charge. An Android phone would just charge while keeping data transmission disabled (because they can be left floating or shorted). This is for security reasons mostly, preventing e.g. a malicious computer from messing with it. An iPhone needs to be unlocked to just charge the damn thing. I'm fairly sure that that's because the data lines need to be pulled up, which could in theory enable a malicious computer to still get some information in or out of it. USB data transmission works at at least 200mV difference between the data lines. It could be more than that. So you need to unlock it.
Apple, how about you just short your goddamn data lines too like everyone else? And while you're at it, get rid of this Lightning connector. I get it, micro USB was too hard for your users. I guess they are blind pigs after all. But USB-C solved all of that and more. The only difference I can think of is that the Lightning connector can be a single board with pads on either side on the connector, while in USB-C that could be at the socket end (socket being less common to be replaced). And at the end of the day, that really doesn't matter with all the other things that will break first.
Think Different. Think Retarded. Such tiny batteries and you can't even fucking charge them properly.6 -
Since we're limiting this to things on my desk I can't do any more deep cuts out of my calculator collection, but this one is still somewhat interesting.
The HP 32S was my friend throughout university, it replaced the 15c I used before which does not live on my desk. The notable thing about the 32s is the fact it's an RPN calculator. RPN calculators are the best way to have friends never ask to borrow your calculator. The exchange will start by them asking to use it, you saying sure, and them handing it back a few minutes later without saying a word.
There's two kinds of people in this world. People who go "wtf" in an interview when asked to create a calculator program using a stack, and people who were oddballs and for whatever reason used reverse polish notation devices.
For those not familiar, rather than entering values into the calculator in "10+10" fashion, you instead provide it a compositional set of values until an operation is provided (10,10,+) at which point it executes. The why is, this type of operation allows the calculator to more naturally process operations, and eliminates the need for parenthesis which makes the operations less error prone in practice and easier to track.
The 32s had a 4 year run before being replaced by the 32SII. In the same way using a Curta will give you a significant understanding of how radix computations and floating points work. Using an HP 32s (or any of its predecessors) will do the same for algebraic functions, because you had to program them yourself using a basic label address system that also had subroutine support.
Kids who grew up with graphing calculators don't know how good you had it 😋4 -
aaAAaaAaaAaaAaAAAAAaAaaa floating points!
I debugged my algorithm for quite a while, wondering why it sometimes gives out "Circle(Point({1.7976931348623157E308,1.7976931348623157E308}),1.7976931348623157E308)" as the smallest circle around a group of points.
Figured out that it sometimes just never found any circle defined by two or three of the points which included all points (which is mathematically impossible).
Then finally I made it print out the points it thought were not inside the circle:
"1,7,8: Circle(Point({0.6636411126185259,0.535709780023259}),0.4985310690982777)
skip, 1 not inside"
So it defined the circle with 1 being on the edge, but then thought 1 was outside. Thank you, floating point Math.
For anyone wondering about the notation: That way I can directly copy/paste it into Geogebra to have a visualisation.7 -
FUCK IEEE 754.
I've always thought that javascript's problem with floating points was just a good anecdote, but it couldn't have serious consequences in real life programming.
Until I've been stuck half an hour with a bug just because (2.8-0.8)%2 was falsy! FUCK, why don't decide to switch to a decent codification of numbers? Fuck them and fuck all programming languages like this5 -
can we just get rid of floating points? or at least make it quite clear that they are almost certainly not to be used.
yes, they have some interesting properties that make them good for special tasks like raytracing and very special forms of math. but for most stuff, storing as much smaller increments and dividing at the end (ie. don't store money as 23.45. store as 2,345. the math is the same. implement display logic when showing it.) works for almost all tasks.
floating point math is broken! and most people who really, truely actually need it can explain why, which bits do what, and how to avoid rounding errors or why they are not significant to their task.
or better yet can we design a standard complex number system to handle repeating divisions and then it won't be an issue?
footnote: (I may not be perfectly accurate here. please correct if you know more)
much like 1/3 (0.3333333...) in base 10 repeats forever, that happens with 0.1 in base 2 because of how floats store things.
this, among other reasons, is why 0.1+0.2 returns 0.300000046 -
Just wasted two hours because C# float.parse only allows dots for decimal places and ignores commas..... But float.tostring uses a comma WTF.
I was writing an obj file exporting the vertices with tostring, then when loading the model would show up broken but in other 3d applications it worked.
Who did come up this bright idea ?2 -
Had a php float value that I needed to use as a string, so I typecasted it.
Later on in the code I need the value again but now it was a string.
Typecasted it back to a floating point.
My colleague almost killed me when he found out what caused the miscalculations.2 -
My visceral hate of Spring.Net burns with the force of a thousand suns.
Almost everything it does is done wrong or solved better by other solutions.
Specifying which classes to instantiate from .xml files? Sure why not, compile type safety (the whole reason for using a static programming language) is obviously overrated and dependency based injection is surely impossible!
And for extra bonus points, now our client code must be aware of the internals of the service classes, and all of their references as well, because, encapsulation? Who cares.
Have you made an typo? Good fucking luck finding out from which of the 100 config files we have floating around...
And, because it has baked in AOP and Transactions its woven into the fabric of the project like a tapewom.
Of course this may just be how our "special snowflake" project uses Spring.
What makes it more painful is that I love good DI tools (ninject, castlewindsor, autofac, there are so many...) and we're stuck with this turd because 7 years ago some java devs couldn't be arsed to learn a new library...1 -
Ok so the real question is, if the Floating Points have some limitation in accuracy, how do Supercomputers Handle that?12
-
Best way to learn C? Might be my ADHD brain,but I'd love to try learning C again. I know K&R is still pretty good,but what are some other books,or good ways to learn C? I'll be using a standard Linux system with gcc so nothing really special. Also Correct me if I'm wrong,but GCC supports later C standards C99,etc except for floating points right?3