Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

VikingofRock posted:

I just wish floats were associative, and that it was a little easier to do stuff like summing products without losing precision. For all that I was joking about posits earlier, I actually do think the general goals of unums / posits are pretty admirable.

unfortunately non-associativity is inherent in fixed-width floating-point

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Athas posted:

What should the default number type be?

do it Ada-style and permit the declaration of integer types with arbitrary ranges

code:
type Page_Num  is range 1 .. 2_000;
type Line_Size is range 1 .. Max_Line_Size;

subtype Small_Int   is Integer   range -10 .. 10;
subtype Column_Ptr  is Line_Size range 1 .. 10;
subtype Buffer_Size is Integer   range 0 .. Max;

type Byte        is mod 256; -- an unsigned byte
type Hash_Index  is mod 97;  -- modulus is prime

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

god I covet ranges as type information. so righteous

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

tef posted:

there's this long post about posits being a scam

https://marc-b-reynolds.github.io/math/2019/02/06/Posit1.html

anyway somewhere halfway through it, there's this graph of relative error and posits do not look great

i'd attach it but i'm too lazy to resize a screenshot to make it upload

thanks for the link. sounds like posits are “not awful, not actually better than IEEE floats, but can be made to seem better on some relatively meaningless comparisons”. Posits are better on some part of some of the error graphs, but big meh.

I did like the pithy statements about just doing math to improve stability and conditioning instead of doing the exact same dumb calculation with more better number representations.

akadajet
Sep 14, 2003

Internet Janitor posted:

do it Ada-style and permit the declaration of integer types with arbitrary ranges

code:
type Page_Num  is range 1 .. 2_000;
type Line_Size is range 1 .. Max_Line_Size;

subtype Small_Int   is Integer   range -10 .. 10;
subtype Column_Ptr  is Line_Size range 1 .. 10;
subtype Buffer_Size is Integer   range 0 .. Max;

type Byte        is mod 256; -- an unsigned byte
type Hash_Index  is mod 97;  -- modulus is prime

sounds useful

Presto
Nov 22, 2002

Keep calm and Harry on.

Athas posted:

What should the default number type be?

Linked list of bits.

Bloody
Mar 3, 2013

succ

redleader
Aug 18, 2005

Engage according to operational parameters
oh boy, is my face red. i thought .net decimal was a fixed point type, but it's a floating point one! i think i conflated it with sql server's decimal type (which is a fixed point type)

although the .net decimal type uses base 10, meaning you can do normal person math on it without it going wildly wrong

i think i've refined my position to be: floating point, whatever, but you should also be able to easily do Normal People Maths on the computer. and langs should facilitate that

Athas
Aug 6, 2007

fuck that joker

Internet Janitor posted:

do it Ada-style and permit the declaration of integer types with arbitrary ranges

code:
type Page_Num  is range 1 .. 2_000;
type Line_Size is range 1 .. Max_Line_Size;

subtype Small_Int   is Integer   range -10 .. 10;
subtype Column_Ptr  is Line_Size range 1 .. 10;
subtype Buffer_Size is Integer   range 0 .. Max;

type Byte        is mod 256; -- an unsigned byte
type Hash_Index  is mod 97;  -- modulus is prime

Integers are easy, the problem is what to do when people want fractions.

Athas
Aug 6, 2007

fuck that joker

VikingofRock posted:

a symbolic expression, which is then computed to arbitrary precision when it's time to output the results

Yeah this IMO, this has the much more amusing error case that the storage requirement for intermediate results can grow arbitrarily due to irreducible fractions, so to a novice the numbers just become slower for no visible reason. I'd really like to visit the parallel universe where this is what Javascript did, so I could see which bizarre cargo cult tricks novices come up with as workarounds.

I think it is pretty cool how IEEE floating point lets people who have no idea about numerical issues (most people, including me) actually write numerical programs that work OK most of the time. All the other proposed systems have far worse idiot-case behaviour.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Lunar Suite posted:

healthcare IT is a gently caress, and the successor product we're forced to upgrade to next year is somehow worse than this ancient and venerable colossus.

which of your current system and your new system are written in MUMPS

(a) current
(b) new
(c) both
(d) neither

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

DELETE CASCADE posted:

chris lattner peaked with llvm and it's been all downhill from there

clang and its C++ stdlib are quite good

unfortunately Chris doesn’t seem to truly feel the fundamental beauty and power of LISP

Kazinsal
Dec 13, 2011


a lot of my employer's services business is in the (admittedly canadian) healthcare field, and we see some poo poo

never had to deal with any of the code end of their stuff but the weirdest stuff that we touch seems to be working with the million disjointed bits on the hardware side. virtualization, storage, networking... it's a miracle if even a quarter of one of those things works right

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Internet Janitor posted:

do it Ada-style and permit the declaration of integer types with arbitrary ranges

code:
type Page_Num  is range 1 .. 2_000;
type Line_Size is range 1 .. Max_Line_Size;

subtype Small_Int   is Integer   range -10 .. 10;
subtype Column_Ptr  is Line_Size range 1 .. 10;
subtype Buffer_Size is Integer   range 0 .. Max;

type Byte        is mod 256; -- an unsigned byte
type Hash_Index  is mod 97;  -- modulus is prime

Dylan did this really well because in the original language definition you could not only explicitly define named constrained types like this for use elsewhere, but also define them inline in a method definition

if your method only worked on a specific range, you could just say so in the definition and call sites would warn

you could even specialize methods for individual instances of parameter types—and before a bunch of “let’s try to roll back some dynamic behavior” revisions, you could even do so on the fly leading to interesting features like methods that can memorize expensive computations for specific parameters at the language level rather than by (more) explicit maintenance of a cache

akadajet
Sep 14, 2003

Athas posted:

Integers are easy, the problem is what to do when people want fractions.

sounds like an exercise for the user to implement.

Cybernetic Vermin
Apr 18, 2005

javascript should just have adopted TeX model of arithmetic wholesale.

akadajet
Sep 14, 2003

Cybernetic Vermin posted:

javascript should just have adopted TeX model of arithmetic wholesale.

javascript does numbers right. "it's a number, worrying about the implementation is for losers writing c or whatever."

ColTim
Oct 29, 2011
Hmm, I just learned that the Playstation 1 didn't have a FPU and only used fixed point numbers (having a bunch of graphical artifacts as a consequence).

Cybernetic Vermin
Apr 18, 2005

ColTim posted:

Hmm, I just learned that the Playstation 1 didn't have a FPU and only used fixed point numbers (having a bunch of graphical artifacts as a consequence).

i just learned that you never played a ps1 game

akadajet
Sep 14, 2003

wobbly textures are a vibe.

Cybernetic Vermin
Apr 18, 2005

it was an interesting time in that the ps1 and the n64 could not have been more different steps into 3d graphics

like, same gen trying to do the same thing, and you could always tell their output apart from a mile away

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

emulators like Duckstation (or maybe just Duckstation) can fix wobbly textures these days with some math that I’m sure I would not understand

working on an emulator seems like it would be right up my VM/compiler/performance alley, but I am always intimidated by the math part

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

ColTim posted:

Hmm, I just learned that the Playstation 1 didn't have a FPU and only used fixed point numbers (having a bunch of graphical artifacts as a consequence).
Even the rasterizer had no subpixel precision causing triangles to shake and not line up correctly. Also, no Z-Buffer.

Dylan16807
May 12, 2010

redleader posted:

although the .net decimal type uses base 10, meaning you can do normal person math on it without it going wildly wrong

i think i've refined my position to be: floating point, whatever, but you should also be able to easily do Normal People Maths on the computer. and langs should facilitate that

decimal isn't much better, you can't reliably do things like add 1/3 to 2/3

decimal is great when you have very specific base ten rounding rules, but most of those cases actually want fixed point math, and fixed point binary gives the same results as fixed point decimal

the rest of the time decimal float is almost entirely as tricky as binary float

Zlodo
Nov 25, 2006
also the ps1 had no perspective correction on texturing which is why texture were sliding like that (artists would subdivide long polygons to reduce the problem)

the video memory was fun too, it was a giant rectangular buffer that had to be addressed with 2d coordinates (and you'd define a rectangular area to be sent to the screen). on the engine i had worked with they had implemented texture memory management with a quadtree

texture mapping was faster if the textured polygons were oriented in the same direction as they were in video memory and slower if they were at a 90 angle

Grum
May 7, 2007

Subjunctive posted:

emulators like Duckstation (or maybe just Duckstation) can fix wobbly textures these days with some math that I’m sure I would not understand

working on an emulator seems like it would be right up my VM/compiler/performance alley, but I am always intimidated by the math part
the conspiracy among graphics peeps is to get interested lay people to write a ray tracer but what they never mention is that writing a software triangle rasterizer with perspective correct texture mapping is also a weekend project

Grum fucked around with this message at 20:17 on Oct 24, 2023

Sapozhnik
Jan 2, 2005

Nap Ghost
for the longest time i didn't know why the modelview matrix and projection matrix had to be separate until i realized that linear interpolation of texture co-ordinates yields a result that is mostly, but not entirely, correct.

but yeah that's what the ps1 did since its triangle rasterizer is an entirely 2D device with no concept of a Z dimension.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
me and my demoscene buddy were so proud of ourselves ca. 1998 when we not only had a perspective correct triangle filler but also implemented the 3d clipping algorithm from Foley and Van Dam. we spent hours skimming the surface of a cube, the polygons not breaking up.

we didn't get out much

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Athas posted:

Integers are easy, the problem is what to do when people want fractions.

type R = Z * N

override Eq R : Eq (n1, d1) (n2, d2) = (n1 * d2 == n2 * d1)

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Cybernetic Vermin posted:

javascript should just have adopted TeX model of arithmetic wholesale.

JavaScript should have never existed in the first place, Netscape should have used Scheme-48 which I believe even at the time supported Scheme’s full numeric tower as designed by mathematicians and computer scientists

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Subjunctive posted:

working on an emulator seems like it would be right up my VM/compiler/performance alley, but I am always intimidated by the math part

work on other parts of the emulator, or on improving MAME

for example, you could fix 68K MMU emulation so A/UX, NetBSD, and MacMach will boot on an emulated Mac IIx

redleader
Aug 18, 2005

Engage according to operational parameters

Dylan16807 posted:

decimal isn't much better, you can't reliably do things like add 1/3 to 2/3

decimal is great when you have very specific base ten rounding rules, but most of those cases actually want fixed point math, and fixed point binary gives the same results as fixed point decimal

the rest of the time decimal float is almost entirely as tricky as binary float

works for me because that's how money works, and money is what an awful lot of code needs to deal with

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Sagacity posted:

me and my demoscene buddy were so proud of ourselves ca. 1998 when we not only had a perspective correct triangle filler but also implemented the 3d clipping algorithm from Foley and Van Dam. we spent hours skimming the surface of a cube, the polygons not breaking up.

we didn't get out much

would have expected a folding chair with 1998 Foley and Van Dam

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull

prisoner of waffles posted:

thanks for the link. sounds like posits are “not awful, not actually better than IEEE floats, but can be made to seem better on some relatively meaningless comparisons”. Posits are better on some part of some of the error graphs, but big meh.

yup

the main "innovation" in posits is variable length exponent encoding. for small exponent values, this frees up bits to store more mantissa. for any word size, ieee has worse precision when encoding numbers whose exponent is close to 0

but like all VL encodings, there's a price - larger exponents need more bits than a fixed length encoding would. so posits actually have worse precision over much of the number line, and a bunch of weird behaviors whenever calculations cause changes in exponent size (because that changes how many bits of mantissa get preserved)

for example, does (x*2) / 2 = x? in any binary floating point system, you'd hope so, since x*2 means "add one to exponent" and x/2 means "subtract one from exponent". as long as x*2 doesn't overflow the exponent field, you ought to get the same number back. with ieee, you do, but with posits, there are many values of x where you do not, even if not triggering exponent overflow

Athas posted:

I think it is pretty cool how IEEE floating point lets people who have no idea about numerical issues (most people, including me) actually write numerical programs that work OK most of the time. All the other proposed systems have far worse idiot-case behaviour.

gustafson often promotes posits by claiming they'll enable naive programmers to safely implement equations right out of math textbooks with no need to think about numerical stability, but this is basically a lie

besides the issue i mention above, a few extra bits of mantissa don't magically save you. gustafson definitely knows this as he spends so much time crafting "IEEE bad" examples by selectively triggering catastrophic cancellation in IEEE. CC is inherent to all attempts at approximating real numbers with finite digits; he could just as easily cherry pick examples where posits suffer CC and IEEE doesn't

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

BobHoward posted:

yup

the main "innovation" in posits is variable length exponent encoding. for small exponent values, this frees up bits to store more mantissa. for any word size, ieee has worse precision when encoding numbers whose exponent is close to 0

but like all VL encodings, there's a price - larger exponents need more bits than a fixed length encoding would. so posits actually have worse precision over much of the number line, and a bunch of weird behaviors whenever calculations cause changes in exponent size (because that changes how many bits of mantissa get preserved)

for example, does (x*2) / 2 = x? in any binary floating point system, you'd hope so, since x*2 means "add one to exponent" and x/2 means "subtract one from exponent". as long as x*2 doesn't overflow the exponent field, you ought to get the same number back. with ieee, you do, but with posits, there are many values of x where you do not, even if not triggering exponent overflow

gustafson often promotes posits by claiming they'll enable naive programmers to safely implement equations right out of math textbooks with no need to think about numerical stability, but this is basically a lie

besides the issue i mention above, a few extra bits of mantissa don't magically save you. gustafson definitely knows this as he spends so much time crafting "IEEE bad" examples by selectively triggering catastrophic cancellation in IEEE. CC is inherent to all attempts at approximating real numbers with finite digits; he could just as easily cherry pick examples where posits suffer CC and IEEE doesn't

yeh, seems enough of an expert to know that what he’s promising is misleading.

tef
May 30, 2004

-> some l-system crap ->

BobHoward posted:

gustafson often promotes posits by claiming they'll enable naive programmers to safely implement equations right out of math textbooks with no need to think about numerical stability, but this is basically a lie

yeah

honestly, if you really need the "extra good" calculations you probably need a real symbolic calculator

tef
May 30, 2004

-> some l-system crap ->
aside, there's always double-double floating point https://www.cs.cmu.edu/~quake/robust.html like this stuff :2bong:

Sapozhnik
Jan 2, 2005

Nap Ghost
actually that's an interesting question, how does big-boy financial software do math anyway? (very carefully)

for basic lemonade-stand financial math sure, you'd count your money in cents (or local equivalent thereof) and do everything in integer arithmetic. decimal percentage calculations on e.g. your tax return work fine too, just multiply and divide by your power-of-ten denominator. compound interest is where you start needing to take exponents though. i guess maybe you can do floating point math to raise 1.05 to the power 30 or whatever and then turn that into a decimal percentage and do the rest with integer math? idk if accountants consider that sort of thing copacetic or not. probably if you're considering say 30 years of annually-compounded 5% interest on a billion dollars then you might want to count your significant figures carefully ($3,321,942,375 and some number of cents i think)

(no this isn't a syq from hacker news)

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sapozhnik posted:

actually that's an interesting question, how does big-boy financial software do math anyway? (very carefully)

integers and multiplication by 1000 or so

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Sapozhnik posted:

actually that's an interesting question, how does big-boy financial software do math anyway? (very carefully)

in excel ????

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply