#bitset
Explore tagged Tumblr posts
Text
I have this idea for a datatype that I'm not sure is a good idea but it's at least neat.
(uints packed into bitsets of course)
You'd still run into funny business around unrepresentable numbers, but we do tend to divide by 3 and 5 a whole lot more than all the other prime numbers that floats don't represent well (3 because sometimes there are 3 of a thing, 5 because every division by 10 is a division by 2-and-5)
NB: When I say "float biased high" what I mean is - stealing a quarter of the bits for prime number divisors lets you create exact representations of various rational numbers you otherwise couldn't, but costs you stuff at the high end - so this probably wouldn't be IEEE-754 but instead shifted over by however much the prime divisors stole.
22 notes
·
View notes
Text
hmmm…so like in C++(20) I need to do two things right now. ok—I wrote this post and it turned out to be 4! (4. Not 4!. Thankfully.) C++ coding diary/questions/difficulties below:
The recursive function I’m working with is structurally the following:
void f(x) {
if(cond) {
successCode
} else {
code1; f(g(x));
if(cond2) { code2; f(h(x)) }
}
}
So, it can either call itself with different arguments—possibly twice, one after the other—or it can succeed.
The way it works, though, is by having code1 and code2 update entries in a global array. (In fact, code1 is simply a[something] = a[somethingElse], and code2 is simply a[something] = 1. cond2 is a[somethingElse] == 0.) So we do have to proceed sequentially to some extent.
Ideally, successCode initiates a possibly computationally intensive task on, say, one of my CPU cores, but spins that off and continues on with the recursive call. However, successCode needs to only spin that process off after it’s finished reading from that global array. (Maybe that part will be trivial.) Further, it needs to stall in the case too many of these processes have been spun off already, and wait for there to be an opening to start.
I’m wondering if std::thread has what I need for that.
2. one thing I’m doing which feels “bad” is: well, I need to have some local constants accessible to a recursive function. Right now I’m essentially just calling f(a, x) where a is unchanged across recursive calls and x changes. Does the compiler know how to handle this correctly…? Is there a better way? Like making a class or something? (I would typically just define this recursive function f(x) inside an outer function that took a as an argument, but you can’t do that directly in C++…)
3. another which feels bad is using this global array! I just need a block of memory whose length is fixed for the majority of the time, but which must be (rarely) grown. does a std::vector give me just as good performance as a really long array, I wonder? The main thing I’m doing is accessing and setting bits at a bunch of different indices, not inserting or growing…and it never grows too large, so maybe a long array is fine.
4. And that’s the other problem—I’m setting bits. that means I get to choose between:
a long (~100?) (and mostly empty most of the time) global array of bools (current, default choice)
the rumored-to-be-cursed std::vector<bool>, which is overridden to be space-efficient instead of a vector of bools—but at the cost of a bunch of its vector-ness! is it better? who knows! half the things on the manual page say “eh, we leave it up to the implementation to decide how or even whether to do this.”
a long and mostly empty most of the time bitset
a boost::dynamic_bitset, which is like a bitset but…dynamic…and I don’t know if that’s better. Like I said I don’t really need to grow it.
what if I just had as many unsigned ints as I needed and manipulated their bits with bitshifting somehow, as though the concatenation of the ints were my array. what then. would that be far worse?
The weird thing is that I don’t need space efficiency, but I do, on each success, need to transform (and alter) the content of this array (or whatever) into something which is space-efficient, but in a weird and bespoke way (I use the last 6 bits of bytes). that means im either constantly converting integer indices into (whichByte, whichBit) pairs and accessing/setting bit values in bytes at the result, or I’m doing one single translation of the whole array each successCode. hard for me to say which is more efficient without testing…but the second *seems* better somehow. but integer operations might be really fast. idk.
2 notes
·
View notes
Text
whoever made bitset little-endian should be shot thank you
0 notes
Text
Representing Type Lattices Compactly
https://bernsteinbear.com/blog/lattice-bitset/
0 notes
Text
Emily Wilde's Map of the Otherlands by Heather Fawcett
Source: NetGalley, thank you to the publisher!TL;DR: An excellent follow-up to the second, and a very good setup for a third Plot: Emily & Wendell go on a search for the Nexus to find Wendell’s door and happen to solve a few mysteries along the wayCharacters: I love Emily & Wendell quite a bit, but the addition of Rose and Ariadne was lovely. They helped flesh it out a bitSetting: This one was…
View On WordPress
0 notes
Text
printf の書式は分かるのに std::cout で桁揃えする方法を思い出せないときに見るエントリ
概要
printf の書式はソラで書けるけど std::cout で同じことをする方法が出てこない俺のためのチートシート。特に std::format が使えない環境のための覚書。
書式
#include <iostream> #include <iomanip> // std::setw, std::setfill #include <bitset> // std::hex #include <format> // C++20
int i = 123;
// Output: "i = 123(0x007b)" printf("i = %4d(0x%04x)\n", i, i); std::cout << "i = " << std::setfill(' ') << std::setw(4) << i << "(0x" << std::setfill('0') << std::setw(4) << std::hex << i << ")" << std::endl; std::cout << std::format("i = {:4d}(0x{:04x})", i, i) << std::endl; // C++20
double d = 12.345;
// Output: "d = 012.35" printf("d = %06.2f\n", d); std::cout << "d = " << std::setfill('0') << std::setw(6) << std::fixed << std::setprecision(2) << d << std::endl; std::cout << std::format("d = {:06.2f}", d) << std::endl; // C++20
補足
左寄せ, 両寄せを使用する場合は #include して std::left, std::right, std::internal を適宜追加
std::showbase を使用すると std::setw の値が読みにくくなるので使わない
std::format は同じ引数を複数回参照できるが読みにくくなるので使わない
空白埋めだけでよいなら std::setfill は不要
末尾の改行なしで即時出力したいなら std::endl の代わりに std::flush を使う
0 notes
Text
This Week in Rust 502
Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @ThisWeekInRust on Twitter or @ThisWeekinRust on mastodon.social, or send us a pull request. Want to get involved? We love contributions.
This Week in Rust is openly developed on GitHub and archives can be viewed at this-week-in-rust.org. If you find any errors in this week's issue, please submit a PR.
Updates from Rust Community
Official
Rustfmt support for let-else statements
Newsletters
This Month in Rust GameDev #46 - May 2023
Project/Tooling Updates
rust-analyzer changelog #188
Pavex DevLog #5: redesigning our runtime types
Bevy XPBD: A physics engine for the Bevy game engine
complgen: Generate {bash,fish,zsh} completions from a single EBNF-like grammar
projectable: a command line TUI file manager
Observations/Thoughts
How To Wrap Your Errors With Enums When Using Error-Stack
Exploring Graphs in Rust. Yikes
Writing a Linked List in Rust: A Walkthrough
Tree-Structured Concurrency
Rust Notes on Temporary values (usage of Mutex) - 4
Method Overloading (kinda), and Advanced Trait Usage
Unlocking Possibilities: 4 Reasons Why ESP32 and Rust Make a Winning Combination
The magic of dependency resolution
Writing E2E Tests for Axum & GraphQL
Detailed web-based 3D rendering of mining spatial data
[video] Choose the Right Option
[video] 4 levels of Rust error handling
Rust Walkthroughs
Build a Ray Tracer, pt. 4 - The Next Dimension
Nine Rules for Running Rust on the Web and on Embedded: Practical Lessons from Porting range-set-blaze to no_std and WASM
Full Stack Rust Workshop: Shuttle, Actix Web, SQLx & Diouxus
Intercepting Allocations with the Global Allocator
A compressed indexable bitset
A persistent task queue in Rust
How I finally understood async/await in Rust (part 2: how does a pending future get woken?)
Miscellaneous
Verify Rust code in VS Code with the Kani VS Code extension
Reduce memory footprint by about 600% for M.E.D. — Performance Matters
New MeetUp Group in Canada: Rust Halifax
Crate of the Week
This week's crate is rustypaste, a minimal file upload/pastebin service.
Thanks to orhun for the self-suggestion!
Please submit your suggestions and votes for next week!
Call for Participation
Always wanted to contribute to open-source projects but did not know where to start? Every week we highlight some tasks from the Rust community for you to pick and get started!
Some of these tasks may also have mentors available, visit the task page for more information.
diesel - Most wanted missing features in diesel 1
diesel - Most wanted missing guide topic 1
css-inline - C bindings
mfcc-rust - create npy files for testing the input and output of cacheable functions
mfcc-rust - make all functions generic over f32 and f64
mfcc-rust - migrate mfcc to depend on mel_spectrogram
ockam - Change argument for ockam credential issue command from Identity to IdentityIdentifier 2
ockam - Use a background node for ockam project enroll 1
ockam - ockam project ticket should return a proper error message 1
RustQuant - Logistic regression is too slow (specifically the matrix inversions).
RustQuant - Implement a user interface (TUI or GUI).
RustQuant - Implement a Postgres interface. 1
RustQuant - Pricing model calibration module.
RustQuant - Add/improve documentation (esp. math related docs).
RustQuant - Increase test coverage (chore). 1
RustQuant - Compute returns from Yahoo finance data reader.
mirrord - mirrord shows loopcrashbackoff pods as possible targets 1
mirrord - Log problem in layer and exit when agent image is not found 1
Hyperswitch - Implement Code coverage for local system using Makefile
Hyperswitch - Add scoped error enum for customer error
Hyperswitch - move redis key creation to a common module
If you are a Rust project owner and are looking for contributors, please submit tasks here.
Updates from the Rust Project
410 pull requests were merged in the last week
support embedding LLVM bitcode on AIX
support for native WASM exceptions
fix(resolve): skip assertion judgment when NonModule is dummy
thir: Add Become expression kind
account for late-bound vars from parent arg-position impl trait
add -Zremark-dir unstable flag to write LLVM optimization remarks to YAML
add bidirectional where clauses on RPITIT synthesized GATs
add check for ConstKind::Value(_) to in_operand()
avoid calling queries during query stack printing
better messages for next on a iterator inside for loops
detect actual span for getting unexpected token from parsing macros
don't perform selection if inherent associated types are not enabled
don't suggest move for borrows that aren't closures
encode item bounds for DefKind::ImplTraitPlaceholder
error when RPITITs' hidden types capture more lifetimes than their trait definitions
export AnalysisResults trait in rustc_mir_dataflow
fix dropping_copy_types lint from linting in match-arm with side-effects
fix associated items effective visibility calculation for type privacy lints
fix type privacy lints error message
fix unset e_flags in ELF files generated for AVR targets
implement deep normalization via the new solver
implement most of MCP510
implement proposed API for proc_macro_span
implement selection via new trait solver
lint/ctypes: ext. abi fn-ptr in internal abi fn
make associated type bounds in supertrait position implied
make compiletest aware of targets without dynamic linking
make the Elaboratable trait take clauses
normalize opaques with late-bound vars again
normalize types when applying uninhabited predicate
privacy: type privacy lints fixes and cleanups
properly implement variances_of for RPITIT GAT
refactor metadata emission to avoid visiting HIR
resolve: remove artificial import ambiguity errors
simplify computation of killed borrows
suggest slice::swap for mem::swap(&mut x[0], &mut x[1]) borrowck error
add suggestion for bad block fragment error
use structured suggestion when telling user about for<'a>
mark wrapped intrinsics as inline(always)
make simd_shuffle_indices use valtrees
make UnwindAction::Continue explicit in MIR dump
mir opt + codegen: handle subtyping
miri: cargo-miri: better error message when RUSTC is not set
miri: make --quiet actually do something
miri: optional semantics for Unique
shrink error variants for layout and fn_abi
a mish-mash of micro-optimizations
codegen_gcc: add support for #[cold] attribute
allow comparing Boxes with different allocators
make rustc_on_unimplemented std-agnostic
stabilize const_cstr_methods
cargo: add READMEs for the credential helpers
cargo: don't try to compile cargo-credential-gnome-secret on non-Linux platforms
rustdoc: fix display of long items in search results
rustdoc: fix display of long inline cfg labels
rustdoc: allow whitespace as path separator like double colon
rustdoc: render generic params & where-clauses of cross-crate assoc tys in impls
rustfmt: don't skip semicolon if expressions follow
rustfmt: implement single_line_let_else_max_width
rustfmt: rewrite float literals ending in dots with parens in method calls
rustfmt: switch to tracing for logging
clippy: new lints: manual_try_fold, needless_raw_string_hashes, redundant_at_rest_pattern, tuple_array_conversions, manual_range_patterns, type_id_on_box, needless_pub_self, pub_with_shorthand and pub_without_shorthand
clippy: significant_drop_tightening: fix incorrect suggestion
clippy: arc_with_non_send_sync: don't lint if type has nested type parameters
clippy: let_and_return: lint 'static lifetimes, don't lint borrows in closures
clippy: missing_fields_in_debug: make sure self type is an adt
clippy: needless_raw_string_hashes: only reset hashes needed if not following quote
clippy: option_if_let_else: suggest .as_ref() if scrutinee is of type &Option<_>
clippy: question_mark: don't lint inside of try block
clippy: unused_async: don't lint if function is part of a trait
clippy: useless_vec: add more tests and don't lint inside of macros
clippy: useless_vec: use the source span for initializer
clippy: don't lint manual_let_else in cases where ? would work
clippy: don't lint code from external macros for 8 lints
clippy: make eq_op suggest .is_nan()
clippy: suggest is_some_and over map().unwrap
rust-analyzer: check Workspace Edit ResourceOps
rust-analyzer: disable mir interpreter for targets with different pointer size from host
rust-analyzer: editor/code: enable noImplicitOverride ts option
rust-analyzer: editor/code: use @tsconfig/strictest to define type checking rules
rust-analyzer: don't add panics to error jump list by default
rust-analyzer: fix self and super path resolution in block modules
rust-analyzer: fix data layout of reference to nested unsized structs
rust-analyzer: fix layout of simd types and respect align in mir interpreter
rust-analyzer: fix overflow checking in shift operator
rust-analyzer: fix panic in handle_code_action
rust-analyzer: fix realloc problem in allocating smaller amounts
rust-analyzer: fix runnable detection for #[tokio::test]
rust-analyzer: follow raw pointers in autoderef chain when resolving methods with custom receiver
rust-analyzer: map our diagnostics to rustc and clippy's ones
rust-analyzer: support #[derive_const(Trait)]
Rust Compiler Performance Triage
A quiet week, with a mixed set of improvements and regressions. Overall slightly more improvements than regressions.
Triage done by @simulacrum. Revision range: b5e51db16..52d8c490
4 Regressions, 4 Improvements, 2 Mixed; 0 of them in rollups
51 artifact comparisons made in total
Full report here
Approved RFCs
Changes to Rust follow the Rust RFC (request for comments) process. These are the RFCs that were approved for implementation this week:
No RFCs were approved this week.
Final Comment Period
Every week, the team announces the 'final comment period' for RFCs and key PRs which are reaching a decision. Express your opinions now.
RFCs
[disposition: merge] RFC: Start working on a Rust specification
Tracking Issues & PRs
[disposition: merge] Enable coinduction support for Safe Transmute
[disposition: close] feat: split unsafe_code lint into lint group
[disposition: merge] Correct the Android stat struct definitions
New and Updated RFCs
[new] Create a Testing sub-team
[new] Add f16 and f128 float types
[new] RFC: Nested Cargo packages
[new] Additional float types
Call for Testing
An important step for RFC implementation is for people to experiment with the implementation and give feedback, especially before stabilization. The following RFCs would benefit from user testing before moving forward:
No RFCs issued a call for testing this week.
If you are a feature implementer and would like your RFC to appear on the above list, add the new call-for-testing label to your RFC along with a comment providing testing instructions and/or guidance on which aspect(s) of the feature need testing.
Upcoming Events
Rusty Events between 2023-07-05 - 2023-08-02 🦀
Virtual
2023-07-05 | Virtual (Indianapolis, IN, US) | Indy Rust
Indy.rs - with Social Distancing
2023-07-05 | Virtual (Stuttgart, DE) | Rust Community Stuttgart
Rust-Meetup
2023-07-06 | Virtual (Ciudad de México, MX) | Rust MX
Rust y Haskell
2023-07-11 | Virtual (Buffalo, NY, US) | Buffalo Rust Meetup
Buffalo Rust User Group, July Meetup
2023-07-11 | Virtual (Dallas, TX, US) | Dallas Rust
Second Tuesday
2023-07-11 - 2023-07-13 | Virtual (Europe) | Mainmatter
Web-based Services in Rust, 3-day Workshop with Stefan Baumgartner
2023-07-13 - 2023-07-14 | Virtual | Scientific Computing in Rust
Scientific Computing in Rust workshop
2023-07-13 | Virtual (Edinburgh, UK) | Rust Edinburgh
Reasoning about Rust: an introduction to Rustdoc’s JSON format
2023-07-13 | Virtual (Nuremberg, DE) | Rust Nuremberg
Rust Nürnberg online #27
2023-07-18 | Virtual (Berlin, DE) | OpenTechSchool Berlin
Rust Hack and Learn
2023-07-19 | Virtual (Vancouver, BC, CA) | Vancouver Rust
Rust Study/Hack/Hang-out
2023-07-20 | Virtual (Tehran, IR) | Iran Rust Meetup
Iran Rust Meetup #12 - Ownership and Memory management
2023-07-25 | Virtual (Dallas, TX, US) | Dallas Rust
Last Tuesday
Asia
2023-07-08 | Bangalore, IN | Rust India
Rust India monthly meetup
Europe
2023-07-05 | Lyon, FR | Rust Lyon
Rust Lyon Meetup #5
2023-07-11 | Breda, NL | Rust Nederland
Rust: Advanced Graphics and User Interfaces
2023-07-13 | Berlin, DE | Rust Berlin
Rust and Tell - beer garden Edition
2023-07-13 | Reading, UK | Reading Rust Workshop
Reading Rust Meetup at Browns
2023-07-21 | Nuremberg, DE | Rust Nuremberg
Rust Nuremberg Get Together #2
North America
2023-07-07 | Chicago, IL, US | Deep Dish Rust
Rust Lunch
2023-07-12 | Austin, TX, US | Rust ATX
Rust Lunch - Fareground
2023-07-12 | Waterloo, ON, CA | Rust KW
Overengineering FizzBuzz
2023-07-13 | Lehi, UT, US | Utah Rust
Writing Kuberenetes Operators in Rust
2023-07-13 | Mountain View, CA, US | Mountain View Rust Meetup
Rust Meetup at Hacker Dojo
2023-07-13 | Seattle, WA, US | Seattle Rust User Group
July Meetup
2023-07-18 | San Francisco, CA, US | San Francisco Rust Study Group
Rust Hacking in Person
Oceania
2023-07-11 | Christchurch, NZ | Christchurch Rust Meetup Group
Christchurch Rust meetup meeting
2023-07-11 | Melbourne, VIC, AU | Rust Melbourne
(Hybrid - in person & online) July 2023 Rust Melbourne Meetup
If you are running a Rust event please add it to the calendar to get it mentioned here. Please remember to add a link to the event too. Email the Rust Community Team for access.
Jobs
Please see the latest Who's Hiring thread on r/rust
Quote of the Week
I'm not here to tell you that Rust is the best language....... you should have figured that out by now.
– Jester Hartman on youtube
Thanks to newpavlov for the suggestion!
Please submit quotes and vote for next week!
This Week in Rust is edited by: nellshamrell, llogiq, cdmistman, ericseppanen, extrawurst, andrewpollack, U007D, kolharsam, joelmarcey, mariannegoldin, bennyvasquez.
Email list hosting is sponsored by The Rust Foundation
Discuss on r/rust
0 notes
Text
Black Friday Deal - Day 9

Our 9th #BlackFriday #Deal is this #Milwaukee 40 Piece Impact #BitSet for only £25.99! 🎉🎉 A saving of 30% from #UKPlanettools
And another 5 deals to be released tomorrow Only!
Browse this deal below 👇👇
http://bit.ly/2rxyG3B
Browse the Black Fridays Deals below 👇👇
http://bit.ly/2KEF0Nn
Deals available from 18/11-30/11
#makita#UKPlanetTools.#buytoolsonline#onlinetoolsshopping#blackfridaydeals#blackfridaysale#blackfridayoffer#blackfriday#milwaukee#bitset
0 notes
Photo

Purchased this #securitybitset 🔧🔩 More #tools ... cause it’s never enough. Lol. Plus I like to be prepared for anything and everything!!! 😉 If you require any computer or electronic devices for your home or business, contact us at [email protected] 647-417-3605 Kunsten Technologies Inc. ~ Technology at your fingertips! . . . . #bitset #cooltools #toolsofthetrade #technology #tech #techie #toronto #yorkregion #mississauga #oakville #burlington #hamilton #thornhill #richmondhill #markham #gta #greatertorontoarea #kunstentech (at Toronto, Ontario) https://www.instagram.com/p/Bt1EbrjgOrr/?utm_source=ig_tumblr_share&igshid=3wf02xxsv7tu
#securitybitset#tools#bitset#cooltools#toolsofthetrade#technology#tech#techie#toronto#yorkregion#mississauga#oakville#burlington#hamilton#thornhill#richmondhill#markham#gta#greatertorontoarea#kunstentech
0 notes
Text
BITSAT Admit Card 2020 released, see here - Latest Breaking News
BITSAT Admit Card 2020 released, see here – Latest Breaking News
[ad_1]
New Delhi: Birla Institute of Technology and Science (BITS) Pilani has released the admit card for Birla Institute of Technology and Science Admission Test (BITSAT) on its official website on today i.e. 13 September.
Candidates who have applied for BITSAT 2020 can visit BITS Pilani’s official website – bitadmission.com to check and download their admit card.
Candidates can download…
View On WordPress
#admit#BITSAT#BITSAT 2020 Admit Card#BITSAT Admit Card 2020#Bitset 2020#Bitset admit card#Breaking#card#Education News#Exam News#Latest#News#released
0 notes
Photo

Torsion Screwdriver Bit Set Only $26.37 Set. Sale ends Sept 30, 2017. Features and Benefits: Includes 14 Torsion cold forged insert bits Cold forged manufacturing process creates superior fitment Specially heat treated for hardness. Offers durability Cylindrical body geometry allows for greater torque load. https://aadiscountauto.ca/special/1039/torsion-screwdriver-bit-set.html
0 notes
Photo

145pcs Rotary Tool Accessories Bit Set Grinding Sanding Polishing Kits #grinderset #bitset #bitkit #sandingkit http://buff.ly/2sIVFnv
0 notes
Photo

Part 2 - Travel tool kit contents: @maxpedition #edcpouch , #paracord , #sharpie , #notepad , #gafatape , @leathermanau #rev , #pen , #steelrule , #driver #bitset #extension , #cableties . This is an ever evolving kit, still have some gear upgrades and additions planned 😀 #gear #kit #loadout #backup #tools #prepared #travelkit #gearplusgadgets
#bitset#gearplusgadgets#gear#extension#gafatape#notepad#cableties#rev#steelrule#kit#travelkit#pen#sharpie#tools#paracord#prepared#driver#loadout#backup#edcpouch
0 notes
Text
C/C++ Macro & Bit Operations
Setting a bit Use the bitwise OR operator (|) to set a bit. number |= 1 << x; That will set bit x.
Clearing a bit Use the bitwise AND operator (&) to clear a bit. number &= ~(1 << x); That will clear bit x. You must invert the bit string with the bitwise NOT operator (~), then AND it.
Toggling a bit The XOR operator (^) can be used to toggle a bit. number ^= 1 << x; That will toggle bit x.
Checking a bit You didn’t ask for this but I might as well add it. To check a bit, AND it with the bit you want to check: bit = number & (1 << x); That will put the value of bit x into the variable bit.
#define bitset(byte,nbit) ((byte) |= (1<<(nbit))) #define bitclear(byte,nbit) ((byte) &= ~(1<<(nbit))) #define bitflip(byte,nbit) ((byte) ^= (1<<(nbit))) #define bitcheck(byte,nbit) ((byte) & (1<<(nbit)))
2 notes
·
View notes
Text
C++ bitset Functions
The various C++ bitset functions are as follows:

0 notes