Computing desk | ||
---|---|---|
< May 23 | << Apr | May | Jun >> | May 25 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
In most contexts, zero holds a unique place: it's neither negative nor positive, because it sits in the very middle, and the numerical values of all other numbers represent their distance from zero in a number line context. In computing contexts with signed zeroes, does anything occupy the median, neither-negative-nor-positive place occupied by zero in other contexts? Nyttend ( talk) 02:20, 24 May 2017 (UTC)
Do you mean like a datum?-- Shantavira| feed me 08:02, 24 May 2017 (UTC)
0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1!=1
, but that's because of rounding in the addition, not because of anything to do with the comparison) with toleranced comparison produces a non-transitive "equality" which, not being an
equivalence relation, invalidates many sensible uses of equality (e.g., in conjunction with
hashing). Which form of comparison to use thus depends on understanding the problem, not on knowing a "good programmer" rule. --
Tardis (
talk) 13:48, 26 May 2017 (UTC)
Oh boy - this is the second time this week I've had to deal with somebody storing booleans in floating-point data types... For better or for worse, programmers of most computer software can interpret bit patterns in any way they like. Most of the time, they choose to use standard bit representations, because it's easier and more consistent and it's harder to mess up. But - if you needed some kind of extra special tagging system for a particular application - beyond the mathematical conventions used in standard representations like IEEE-754, then could pack additional status into a compound data type (a "struct," in many languages). To do so in a way that is simultaneously useful, mathematically rigorous, and extensible - WLOG, as the mathematicians say - would be very difficult. But you could! Consider:
int main(int argc, char** argv)
{
typedef enum {
positive,
negative,
exactly_zero
} sign_convention;
typedef struct
{
double value;
sign_convention flag;
} number;
number x;
x.value = 2.718;
x.flag = exactly_zero;
return 0;
}
/* Note to novice programmers: don't do this. */
/* Note to advanced programmers: don't do this either. */
This is a legal C program and it compiles without any problem on my computers. How you wish to interpret a "number" data type whose sign convention flag differs from its value is at your discretion. But before you say it is wrong - consider that in modern mathematics, we have the power of definition. If, for the purposes of my application, I define the positive-ness or negative-ness of my data type to depend only and exclusively on my sign_convention flag, then I have the freedom to use this in whatever fashion I see fit. If I had decided to be particularly obtuse, I could have used type punning to pack the status-flag inside the value, provided that I used the value with extraordinary caution. In response to the original question's implicit ask: why would we ever do this? Why not just use positive and negative floats the way our forebears intended? My mind races toward interesting use of the negative sign in various elements of graph theory and topology and oriented surfaces in arbitrary dimension; and toward the esoteric basis-sets that extend the real plane into higher dimensions (like the quaternion); and so on. These are very real and very common data types. It is a near-certainty that the computer you are using right now includes a graphics-processing arithmetic unit that is capable of using, and interpreting, such esoteric sign conventions - at least in its internal data representations. As our great computer scientists frequently remind us, we can and should exercise our brains, and reevaluate the fundamental mathematical assumptions that exist in our standard machine representations of numeric theory. Messing around with the way your machine automates its sign convention might shake out a fundamental flaw in your application-software. It never hurts to inject a little bit of paranoia into your floating point code. Nimur ( talk) 14:24, 24 May 2017 (UTC)
Oh boy - this is the second time this week I've had to deal wih somebody storing booleans in floating-point data types<reads this quote and just nopes the hell away from this thread> ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 12:54, 25 May 2017 (UTC)
I was searching for, "HOW TO MANAGE E-BOOKS ON ELECTRONICS" on this website and others for days now. I really need the answer so I will know how to do this.
ENID BLITON ( talk) 23:44, 24 May 2017 (UTC) WEDNESDAY 24TH MAY,2017
Computing desk | ||
---|---|---|
< May 23 | << Apr | May | Jun >> | May 25 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
In most contexts, zero holds a unique place: it's neither negative nor positive, because it sits in the very middle, and the numerical values of all other numbers represent their distance from zero in a number line context. In computing contexts with signed zeroes, does anything occupy the median, neither-negative-nor-positive place occupied by zero in other contexts? Nyttend ( talk) 02:20, 24 May 2017 (UTC)
Do you mean like a datum?-- Shantavira| feed me 08:02, 24 May 2017 (UTC)
0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1!=1
, but that's because of rounding in the addition, not because of anything to do with the comparison) with toleranced comparison produces a non-transitive "equality" which, not being an
equivalence relation, invalidates many sensible uses of equality (e.g., in conjunction with
hashing). Which form of comparison to use thus depends on understanding the problem, not on knowing a "good programmer" rule. --
Tardis (
talk) 13:48, 26 May 2017 (UTC)
Oh boy - this is the second time this week I've had to deal with somebody storing booleans in floating-point data types... For better or for worse, programmers of most computer software can interpret bit patterns in any way they like. Most of the time, they choose to use standard bit representations, because it's easier and more consistent and it's harder to mess up. But - if you needed some kind of extra special tagging system for a particular application - beyond the mathematical conventions used in standard representations like IEEE-754, then could pack additional status into a compound data type (a "struct," in many languages). To do so in a way that is simultaneously useful, mathematically rigorous, and extensible - WLOG, as the mathematicians say - would be very difficult. But you could! Consider:
int main(int argc, char** argv)
{
typedef enum {
positive,
negative,
exactly_zero
} sign_convention;
typedef struct
{
double value;
sign_convention flag;
} number;
number x;
x.value = 2.718;
x.flag = exactly_zero;
return 0;
}
/* Note to novice programmers: don't do this. */
/* Note to advanced programmers: don't do this either. */
This is a legal C program and it compiles without any problem on my computers. How you wish to interpret a "number" data type whose sign convention flag differs from its value is at your discretion. But before you say it is wrong - consider that in modern mathematics, we have the power of definition. If, for the purposes of my application, I define the positive-ness or negative-ness of my data type to depend only and exclusively on my sign_convention flag, then I have the freedom to use this in whatever fashion I see fit. If I had decided to be particularly obtuse, I could have used type punning to pack the status-flag inside the value, provided that I used the value with extraordinary caution. In response to the original question's implicit ask: why would we ever do this? Why not just use positive and negative floats the way our forebears intended? My mind races toward interesting use of the negative sign in various elements of graph theory and topology and oriented surfaces in arbitrary dimension; and toward the esoteric basis-sets that extend the real plane into higher dimensions (like the quaternion); and so on. These are very real and very common data types. It is a near-certainty that the computer you are using right now includes a graphics-processing arithmetic unit that is capable of using, and interpreting, such esoteric sign conventions - at least in its internal data representations. As our great computer scientists frequently remind us, we can and should exercise our brains, and reevaluate the fundamental mathematical assumptions that exist in our standard machine representations of numeric theory. Messing around with the way your machine automates its sign convention might shake out a fundamental flaw in your application-software. It never hurts to inject a little bit of paranoia into your floating point code. Nimur ( talk) 14:24, 24 May 2017 (UTC)
Oh boy - this is the second time this week I've had to deal wih somebody storing booleans in floating-point data types<reads this quote and just nopes the hell away from this thread> ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 12:54, 25 May 2017 (UTC)
I was searching for, "HOW TO MANAGE E-BOOKS ON ELECTRONICS" on this website and others for days now. I really need the answer so I will know how to do this.
ENID BLITON ( talk) 23:44, 24 May 2017 (UTC) WEDNESDAY 24TH MAY,2017