Flags - flags and setf

Pages: 123
closed account (jvqpDjzh)
//Hello guys!!!

//First, how should you translate flags into a understanble language? They could call them like iosettings or iotools, right? Why "they" call "them" flags?

//Second, what are the differences between flags() and setf()?
Last edited on


//First, how should you translate flags into a understanble language?



Basically you would check the bits for either a 1 usually to represent a on and a 0 for an off, depending on the state of the bit you perform a certain action.
Something like if(bit is on) then drop a coke from the vending machine. if (bit is off) nobody paid for the soda don't give it to them.



They could call them like iosettings or iotools, right? Why "they" call "them" flags?



They are called flags because the represent a marker much like a the American flag on the moon does, we are Americans and we own the moon :P. And well because that just easier. iosettings or iotools make them a bit more cryptic in my opinion.
Last edited on
Slightly more seriously. the idea is that a flag is a signal. If the flag is raised, it means one thing, and if it's lowered then it means another. That's analogous to a boolean value - if the value is 1, then it indicates one thing, and if it's 0 it means another.

It's a bit of jargon that crept into the programming vocabulary decades ago.
closed account (jvqpDjzh)
Ok. Thank you to y'all. One thing: is there a stream manipulator or a cout function that centers the output in a certain width we decide? There's a the stream right and left manipulator, but I didn't found the center one. And what internal manipulator does?
closed account (jvqpDjzh)
And also: why isn't there a stream manipulator or a cout function to have the lowercase: as we have the uppercase manipulator, it seems quite unlogical.
zwiluwu wrote:
And also: why isn't there a stream manipulator or a cout function to have the lowercase: as we have the uppercase manipulator, it seems quite unlogical.
It's a flag that can be either on or off. Would it makes sense to be neither upper nor lower case, or both at the same time?

http://en.cppreference.com/w/cpp/io/manip/uppercase

EDIT: Added quote.
Last edited on
std::uppercase - std::nouppercase
http://en.cppreference.com/w/cpp/io/manip


> And what internal manipulator does?

Example at the bottom of this page: http://en.cppreference.com/w/cpp/io/manip/left
Last edited on
closed account (jvqpDjzh)

LB


// I think that there should be an lowercase manipulator, that when it is on the uppercase, ofc, becomes off, and viceversa, is unlogical that it doesn't exist. And do not be offended because there's no one.
Last edited on
zwiluwu wrote:
// I think that there should be an lowercase manipulator, that when it is on the uppercase, ofc, becomes off, and viceversa, is unlogical that it doesn't exist. And do not be offended because there's no one.
Did you click that link? There is a std::nouppercase, and JLBorges even posted it more directly than me.

EDIT: Added quote.
Last edited on
closed account (jvqpDjzh)
"Enables the use of uppercase characters in floating-point and hexadecimal integer output. Has no effect on input." => this explains my doubt

I thought this manipulator could be used to all kind of output, but instead it is used just for floating-points and hexadecimal. Why?
// I think that there should be an lowercase manipulator, that when it is on the uppercase, ofc, becomes off, and viceversa, is unlogical that it doesn't exist. And do not be offended because there's no one.


please keep clarity in mind what are you actually on about?
closed account (jvqpDjzh)

CodeGoggles



please keep clarity in mind what are you actually on about?


"Please"? ah?

//no comment.
zwiluwu wrote:
I thought this manipulator could be used to all kind of output, but instead it is used just for floating-points and hexadecimal. Why?
Because it has to be either on or off, which would mean that your string output would always be either all lowercase or all uppercase. Instead, you the programmer are expected to format the strings you output yourself. Converting strings to all lowercase or all uppercase is trivial:
http://stackoverflow.com/a/313990/1959975
closed account (jvqpDjzh)
And I am still thinking that should be an lowercase anyway!
What you said doesn't prove that couldn't exist a lowercase manipulator!
You are trying to excuse the C++, but actually C++ defects, unfortunately :(
> it is used just for floating-points and hexadecimal. Why?

For character and string output, we have control; we decide if a particular character is upper case or not.
zwiluwu wrote:
And I am still thinking that should be an lowercase anyway!
What you said doesn't prove that couldn't exist a lowercase manipulator!
You are trying to excuse the C++, but actually C++ defects, unfortunately :(
What you are asking for is a redundant way to do something that can already be done easily. The C++ standards committee does not consider this a defect of the language. If you want, you can search for the full list of defects in C++ and see for yourself.

EDIT: Added quote.
Last edited on
closed account (jvqpDjzh)

LB



Instead, you the programmer are expected to format the strings you output yourself.

//Of course the programmer are expected to, to, to, to, to, to, to...
//No, the standard library should help the programmer, to spares time! (OOP)


Converting strings to all lowercase or all uppercase is trivial:

It's trivial, and? What does it mean? That shouldn't exist a lowercase manipulator?
zwiluwu wrote:
//Of course the programmer are expected to, to, to, to, to, to, to...
//No, the standard library should help the programmer, to spares time! (OOP)
That's not what OOP is. Perhaps you would like a language like PHP where there are a billion ways to do everything?
zwiluwu wrote:
It's trivial, and? What does it mean? That shouldn't exist a lowercase manipulator?
Yes.
Last edited on
closed account (jvqpDjzh)
LB

I am sorry to say... but I think you are a sort of puppet! Can you not think with your head, brain? "The standards, the standards...." -___-

Pages: 123