Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Writing single bits to a file

Reply
Thread Tools

Writing single bits to a file

 
 
CBFalconer
Guest
Posts: n/a
 
      10-29-2007
Kenneth Brody wrote:
> Eric Sosman wrote:
> [...]
>> gets worse: Some of the best compressors encode their output
>> in fractions of bits; if a file length of 10007 bits is bad,
>> a length of 10006.59029663+ bits is *really* bad!

> [...]
>
> I've never heard of that. What's a fraction of a bit? Is it
> something that needs to hold less than two states?


Look up arithmetic compression.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
cr88192
Guest
Posts: n/a
 
      10-30-2007

"Keith Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "cr88192" <(E-Mail Removed)> writes:
>> "Charlie Gordon" <(E-Mail Removed)> wrote in message
>> news:4725f246$0$6594$(E-Mail Removed)...

> [...]
>>> .5==x^.5==y // x equals 0.5 or y equals 0.5 but not both.
>>> .8<x&.9>x
>>> 1.1==x|.9==y
>>> x/.1
>>> y*.2
>>> z-.2
>>> ...
>>>
>>> I always put around binary operators but a lot of programmers don't.

>>
>> odd, I always thought the preceeding decimal digits were required.
>> at least in my parser, the number will not be recognized as a number,
>> unless it starts with a decimal digit, say, '0'...

>
> Take a look at the syntax for a floating-constant, C99 6.4.4.2.
>
> Just as a matter of style, I never use a leading or trailing decimal
> point (I at least prepend or append a 0), but it's permitted.
>


ok, I missed that, having assumed the leading digits were required.

I am not sure if in-practice things are done this way, or not.
2 options here:
disallow floating point numbers lacking a numeric prefix ('.5' being
technically invalid);
adding a 'disambiguation rule', such that whitespace is required following
the dot if following the dot could ambiguously be confused as a
fractional-number.

'2^.3' would thus be invalid (parsed as '2 ^ .3'), and would thus have to be
written:
'2^. 3'.

'^:', is also possible, but IMO uglier, and has potential implications (the
above operator style at least has precedent in a few certain specific
functional languages...).

'^,' is also possible, since these operators are not allowed standalone or
in suffix position.

(just here looking for a rule I can generalize to create a number of
auxilary operators is all).


> --
> Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed)
> <http://www.ghoti.net/~kst>
> San Diego Supercomputer Center <*>
> <http://users.sdsc.edu/~kst>
> "We must do something. This is something. Therefore, we must do this."
> -- Antony Jay and Jonathan Lynn, "Yes Minister"



 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      10-30-2007
"cr88192" <(E-Mail Removed)> writes:
> "Keith Thompson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "cr88192" <(E-Mail Removed)> writes:

[...]
>>> odd, I always thought the preceeding decimal digits were required.
>>> at least in my parser, the number will not be recognized as a number,
>>> unless it starts with a decimal digit, say, '0'...

>>
>> Take a look at the syntax for a floating-constant, C99 6.4.4.2.
>>
>> Just as a matter of style, I never use a leading or trailing decimal
>> point (I at least prepend or append a 0), but it's permitted.

>
> ok, I missed that, having assumed the leading digits were required.
>
> I am not sure if in-practice things are done this way, or not.


I'm not sure what you mean. In practice, all C compilers allow
floating-constants with leading or trailing decimal points.

> 2 options here:
> disallow floating point numbers lacking a numeric prefix ('.5' being
> technically invalid);


If you're designing your own language, you can do that. If you want
something compatible with C, you can't. '.5' is perfectly valid.

[...]

> (just here looking for a rule I can generalize to create a number of
> auxilary operators is all).


Just my opinion: if you have to jump through a lot of hoops to make
something work, you should consider backing off and using a different
approach.

I think I suggested using '@' for any added syntax, since C doesn't
already use it. '$' and '`' are also possibilities (though '`' and
''' can be difficult to distinguish).

Incidentally, please don't quote signatures (the stuff following
"-- ") unless you're actually commenting on them.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
cr88192
Guest
Posts: n/a
 
      10-30-2007

"Keith Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "cr88192" <(E-Mail Removed)> writes:
>> "Keith Thompson" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> "cr88192" <(E-Mail Removed)> writes:

> [...]
>>>> odd, I always thought the preceeding decimal digits were required.
>>>> at least in my parser, the number will not be recognized as a number,
>>>> unless it starts with a decimal digit, say, '0'...
>>>
>>> Take a look at the syntax for a floating-constant, C99 6.4.4.2.
>>>
>>> Just as a matter of style, I never use a leading or trailing decimal
>>> point (I at least prepend or append a 0), but it's permitted.

>>
>> ok, I missed that, having assumed the leading digits were required.
>>
>> I am not sure if in-practice things are done this way, or not.

>
> I'm not sure what you mean. In practice, all C compilers allow
> floating-constants with leading or trailing decimal points.
>


well, it is not so much about compilers or standards, but about existing
code and coding practices.
do people actually write code this way?...
I guess I will have to assume they do.


>> 2 options here:
>> disallow floating point numbers lacking a numeric prefix ('.5' being
>> technically invalid);

>
> If you're designing your own language, you can do that. If you want
> something compatible with C, you can't. '.5' is perfectly valid.
>


yeah.


> [...]
>
>> (just here looking for a rule I can generalize to create a number of
>> auxilary operators is all).

>
> Just my opinion: if you have to jump through a lot of hoops to make
> something work, you should consider backing off and using a different
> approach.
>
> I think I suggested using '@' for any added syntax, since C doesn't
> already use it. '$' and '`' are also possibilities (though '`' and
> ''' can be difficult to distinguish).
>


yeah.
@ and $, are possible, and are good for standalone operators, but not for
masses of operators (for example, with the conventions before, it was fairly
easy to come up with 20+ new possible operators).

@ and $, are ok.
@+, +@, $/, ... now you are just getting ugly...


so, in my view, we need a dominant character, and a softer modifier
character ('.' was considered as a character, because this is what ocaml
did...). (many of the good double-dominant combos are already used
anyways...).



softer modifiers can be:
characters that hopefully have no other contextually meaningful use (thus
leading to ambiguity);
are not visually misleading (IMO, this makes , ; and : bad choices for
modifiers).

+`, -`, ~`, ... are probably better options though, since otherwise this
characher is not used for anything (and in all sanity, this should not clash
with anything). it will be assumed that we know what character it is due to
context.

though still possible, '.' would probably require disambiguating spaces in
too many situations...


so, possible '2`3' representing fexp(2, 3)...


> Incidentally, please don't quote signatures (the stuff following
> "-- ") unless you're actually commenting on them.
>


ok, will try to remember this...


 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      10-30-2007
Keith Thompson <(E-Mail Removed)> writes:

> I think I suggested using '@' for any added syntax, since C doesn't
> already use it. '$' and '`' are also possibilities (though '`' and
> ''' can be difficult to distinguish).


Using any of these would require not just new syntax but an
addition to the basic source character set, which does not
currently contain any of those characters.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1utchar(a[i&15]);break;}}}
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      10-30-2007
Ben Pfaff <(E-Mail Removed)> writes:
> Keith Thompson <(E-Mail Removed)> writes:
>> I think I suggested using '@' for any added syntax, since C doesn't
>> already use it. '$' and '`' are also possibilities (though '`' and
>> ''' can be difficult to distinguish).

>
> Using any of these would require not just new syntax but an
> addition to the basic source character set, which does not
> currently contain any of those characters.


Which is no more problematic than adding new operator symbols.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      10-30-2007
"cr88192" <(E-Mail Removed)> writes:
> "Keith Thompson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "cr88192" <(E-Mail Removed)> writes:

[...]
>>> I am not sure if in-practice things are done this way, or not.

>>
>> I'm not sure what you mean. In practice, all C compilers allow
>> floating-constants with leading or trailing decimal points.

>
> well, it is not so much about compilers or standards, but about
> existing code and coding practices.
> do people actually write code this way?...
> I guess I will have to assume they do.


*What* is about existing code and coding practices?

You're implementing a C-like compiler that provides some significant
set of extensions, right? If you're not concerned about the
requirements of the existing C standard, why post here?

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      10-30-2007
Keith Thompson <(E-Mail Removed)> writes:

> Ben Pfaff <(E-Mail Removed)> writes:
>> Keith Thompson <(E-Mail Removed)> writes:
>>> I think I suggested using '@' for any added syntax, since C doesn't
>>> already use it. '$' and '`' are also possibilities (though '`' and
>>> ''' can be difficult to distinguish).

>>
>> Using any of these would require not just new syntax but an
>> addition to the basic source character set, which does not
>> currently contain any of those characters.

>
> Which is no more problematic than adding new operator symbols.


Sure it is. Why would adding new operators that use characters
that are already in the character set be problematic, especially
if the operators were carefully chosen to avoid ambiguity? But
adding new characters to the character set potentially requires
some people to get new keyboards, fonts, etc., and practically
speaking would necessitate new digraphs, trigraphs, additions to
<iso646.h>, and so on. In the extreme, consider APL.
--
"Some programming practices beg for errors;
this one is like calling an 800 number
and having errors delivered to your door."
--Steve McConnell
 
Reply With Quote
 
Charlie Gordon
Guest
Posts: n/a
 
      10-30-2007
"Ben Pfaff" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> Keith Thompson <(E-Mail Removed)> writes:
>
>> Ben Pfaff <(E-Mail Removed)> writes:
>>> Keith Thompson <(E-Mail Removed)> writes:
>>>> I think I suggested using '@' for any added syntax, since C doesn't
>>>> already use it. '$' and '`' are also possibilities (though '`' and
>>>> ''' can be difficult to distinguish).
>>>
>>> Using any of these would require not just new syntax but an
>>> addition to the basic source character set, which does not
>>> currently contain any of those characters.

>>
>> Which is no more problematic than adding new operator symbols.

>
> Sure it is. Why would adding new operators that use characters
> that are already in the character set be problematic, especially
> if the operators were carefully chosen to avoid ambiguity? But
> adding new characters to the character set potentially requires
> some people to get new keyboards, fonts, etc., and practically
> speaking would necessitate new digraphs, trigraphs, additions to
> <iso646.h>, and so on. In the extreme, consider APL.


While using non ASCII characters would cause headaches, $ and especially @
are now universally supported. I used to program in APL a lot: I stopped
when I no longer had access to the proper keyboard

--
Chqrlie.


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      10-30-2007
Charlie Gordon said:

> I used to program in APL a lot: I stopped
> when I no longer had access to the proper keyboard


Ah, you should have said before. I chucked out an APL keyboard two or three
weeks ago. It'll be about fifteen feet deep in the landfill by now.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing single bits to a file riva Java 2 10-27-2007 08:11 PM
shifting bits, shift 32 bits on 32 bit int GGG C++ 10 07-06-2006 06:09 AM
8 bits/ch vs 16 bits/ch in PS Terry Digital Photography 5 01-21-2004 06:59 PM
8-Bits vs 12 or 16 bits/pixel; When does more than 8 bits count ? Al Dykes Digital Photography 3 12-29-2003 07:08 PM
win XP 32 bits on a 64 bits processor.. Abbyss Computer Support 3 11-13-2003 12:39 AM



Advertisments