I've got Decimal class which implements decimal floating point arithmetic. It can be initialized with an integral arithmetic type or a fractional digit stored as a string. Build-in floating point types are deliberately avoided because of their approximative nature. Such approach works well but fractional digits coded as strings look awkward. Is it possible to use somehow C++ literals to build strings (or binary representation) behind the scene?  Decimal a{"1.254684987"}; // current initialization Decimal b{1.254684987_dec}; // desired way
introduces  which will allow the introduction of new literal syntax based on existing literals (int, hex, string, float) so that any type will be able to have a literal presentation.  Examples:  // imaginary numbers std::complex&lt;long double&gt; operator "" _i(long double d) // cooked form {      return std::complex&lt;long double&gt;(0, d);  } auto val = 3.14_i; // val = complex&lt;long double&gt;(0, 3.14)  // binary values int operator "" _B(const char*); // raw form int answer = 101010_B; // answer = 42  // std::string std::string operator "" _s(const char* str, size_t /*length*/)  {      return std::string(str);  }  auto hi = "hello"_s + " world"; // + works, "hello"_s is a string not a pointer  // units assert(1_kg == 2.2_lb); // give or take 0.00462262 pounds   At first glance this looks very cool but I'm wondering how applicable it really is, when I tried to think of having the suffixes _AD and _BC create dates I found that it's problematic due to operator order. 1974/01/06_AD would first evaluate 1974/01 (as plain ints) and only later the 06_AD (to say nothing of August and September having to be written without the 0 for octal reasons). This can be worked around by having the syntax be 1974-1/6_AD so that the operator evaluation order works but it's clunky.   So what my question boils down to is this, do you feel this feature will justify itself? What other literals would you like to define that will make your C++ code more readable?    Updated syntax to fit the final draft on June 2011
Replacing non-English characters in attribute tables using ArcPy and Python? I have a few shapefiles where some of the attributes contain the non-English characters ÅÄÖ. Since some queries doesn't work with these characters (specifically ), I tried to change them in advance with a simple script and add the new strings to another field.  However, change in characters works fine but not updating the field with arcpy.UpdateCursor.   What is an appropriate way of solving this?  I have also tried to do this via the Field Calculator while posting "code" to the codeblock, with the same error.  Error message: Runtime error  Traceback (most recent call last):   File "", line 1, in    File "c:/gis/python/teststring.py", line 28, in      val = code(str(prow.Typkod)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 3: ordinal not in range(128)  Code:  # -*- coding: cp1252 -*- def code(infield):     data = ''     for i in infield: ##        print i         if i == 'Ä':             data = data + 'AE'         elif i == 'ä':             data = data + 'ae'         elif i == 'Å':             data = data + 'AA'         elif i == 'å':             data = data + 'aa'         elif i == 'Ö':             data = data + 'OE'         elif i == 'ö':             data = data + 'oe'         else:             data = data + i     return data   shp = r'O:\XXX\250000\DB\ArcView\shape.shp'  prows = arcpy.UpdateCursor(shp)  for prow in prows:     val = code(unicode(str(prow.Typkod), "utf-8"))     prow.Typkod_U = val     print val     prows.updateRow(prow)   The values of Typkod are of the type: [D, D, S, DDRÄ, TRÄ] etc.  I use ArcMap Basic (10.1) on Windows 7.    New Error message:  Runtime error  Traceback (most recent call last):   File "", line 1, in    File "c:/gis/python/teststring.py", line 29, in      val = code(unicode(str(row.Typkod), "utf-8")) UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 3: ordinal not in range(128)  &gt;&gt;&gt; val 'DDRÄ' &gt;&gt;&gt; type(val) type 'str'      It appears as if the output from the function is wrong somehow. When there's ÅÄÖ involved it returns data = u'DDR\xc4' and not (as was my intention) data = 'DDRAE'. Any suggestions on what might cause this? Show that $R/I\otimes_R R/J\cong R/(I+J)$ Let $R$ be a commutative ring with identity and $I$ and $J$ be ideals in $R$.     Show that $R/I\otimes_R R/J\cong R/(I+J)$ as $R$-modules.   This is what I tried.  Define a map $f:R/I\times R/J\to R/(I+J)$ as $f(\bar r, \bar s)=rs+(I+J)$. This is a well-defined bilinear map.  By the universal property of tensor products, we get an $R$-linear map $F:R/I\otimes_R R/J\to R/(I+J)$ which sends $\bar r\otimes \bar s$ to $rs+(I+J)$.  This map is surjective.  So all we need to show is that the kernel of $F$ is $0$.  But I am unable to do this. Syntax highlighting language hints Do you think it would be worthwhile to provide hints as to what language to use for the syntax highlighting?  Sometimes I find the highlighting on SQL or VB.NET answers is more distracting than helpful; for example:       to pick the two I've been looking at recently. Solving binomial theorem via induction Acquiring drive names (as opposed to drive letters) in Java On my Windows machine, my main hard drive has the letter C: and the name "Local disk".   To list the drive letters in Java on Windows, the File object has the static listRoots() method. But I can't find a way to acquire the drive names (as opposed to the drive letters) on Windows.  Has anyone tried this before? Why does the Stern–Gerlach quantum spin experiment conflict with classical mechanics? My understanding of the Stern–Gerlach experiment is that neutral (0 total charge) particles are sent through a non-homogeneous magnetic field, with the expectation that the field will push that particle's path higher or lower on a detector because of the collective spin of that particle. While the detector can detect particles in a two-dimensional surface, the results of the experiment are that particles appear in only two localized areas directly above the path of the particle stream, or directly below the path of the particle stream - spin up or spin down. The conclusions from these measurements are that the particle, when measured, will always have about the same magnitude.  Why does this not follow from classical mechanical theory related to magnetism? If you shot a magnet through a similar apparatus, I would expect the magnet to be rotated to align with the magnetic field in some way which, at high enough field strengths relative to the mass of the magnet, would cause us to measure basically the same magnitude as if the magnet entered the apparatus pre-aligned with the field.  How is my explanation incorrect? How to use wc and piping to find how many files and directories are in a certain directory? How can I use word counter (wc) and piping to count how many files or directories are in the /usr/bin directory? Why must we "avoid discussions in comments"? I've just started getting these messages:     Please avoid extended discussions in comments. Would you like to automatically move this discussion to chat?   Why should one avoid doing this? I think it adds to the site...  (Tagged  in more ways than one!) Complex integral over a circle In an exercise, I'm supposed to assume that $|a| &lt; r &lt; |b|$ and prove that $\displaystyle\int_{\gamma} \frac{1}{(z - a)(z - b)} dz = \frac{2 \pi i}{a - b}$, where $\gamma$ is a circle of radius $r$ centered at the origin with positive orientation. So I had the idea to express this integral as $\frac{1}{a - b} \displaystyle\int_{\gamma} \frac{1}{z - a} - \frac{1}{z - b} dz$. Then I tried to evaluate each of these separately, but I don't really know what to do. I get $\displaystyle\int_{0}^{2 \pi} \frac{i r e^{it}}{r e^{it} - a} dt$ for the first term. How am I supposed to integrate this? I can't substitute $u = re^{it}$, can I? \pause in tikzpicture breaks footline I've discovered that you can \pause within a tikzpicture, which works well until I switched the theme to one with a footline.  I've created a "test case" that illustrates the problem.  \documentclass{beamer} \providecommand\thispdfpagelabel[1]{} % Not sure what this does but our installation requires it. \usepackage{tikz} \usetheme{Madrid} % Has a footline.  \begin{document}   \begin{frame}     \frametitle{test}     \begin{tikzpicture}       \node at (0, 1) {Hello};       \pause       \node at (0, 0) {World};     \end{tikzpicture}   \end{frame} \end{document}   This creates two slides, but the footline is only drawn on the second (the headline/title appears on both). Is there anything I can do about this? How do I build a house for my NPCs? Every finitely generated algebra over a field is a Jacobson ring Knowing that the polynomial ring in $n$ variables over a field $k$ is a Jacobson ring, how can we prove from it that every finitely generated $k$-algebra is a Jacobson ring?   EDIT: We define a ring to be Jacobson if every prime ideal is an intersection of maximal ideals. Detecting current iPhone input language For a project into balloon simulation I'd like to know how the force on a balloon changes with altitude:  I know that the Buoyant force on a balloon is:  $F = (\rho_{air} - \rho_{helium})gV$  Using changing air density from the international standard atmosphere and changes in gravitational acceleration I can calculate the buoyant force and add this to the (negative) force of gravity mg.  However I know that it isn't this simple, the balloon changes volume with altitude as the air pressure outside the balloon changes.  I'd like to know how the balloon inflates - this would be a great help!  I think it may be something to do with ideal gas laws -  I can calculate air temperature and pressure from the international standard atmosphere but do I use pressure as the air pressure? - or air pressure minus balloon pressure? How to get the day, year, hours, min Individually from date format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"? For wall-sized graphics and large banners (e.g. 3m × 5m), what is an acceptable PPI for print? As I understand it 300 ppi is the typical for 'small' artworks (esp. for clean text resolution). However, for small artworks, the audience usually engages at a much closer distance. Therefore, in the interests of keeping a bitmap file down to a reasonable size, can you get away with a much-reduced PPI for a large format/banner print? What makes the inside of a shape the inside? I am trying to identify a sci-fi movie from the 80's or 90's, with the following parameters:  Setting:    Scenes of a red desert planet   Culture:    Either people roam fairly solo and try to acquire resources to survive, or you live in a weird society where if a stranger is captured he needs to play in a game of fight to the death.  Mobility:      One foil character has a giant battle-bot-looking tank as his form of transportation through the desert. Protagonist has a car that has a plastic half bubble on top to look out from.   Robot:      The protagonist runs around in the beginning of the film with a female robot/android whose face is melted off after it has acid touch its face.(This scene happens next to the protagonist's rover)  Love interest:      Somehow protagonist comes across female protagonist in desert. She smells really bad and is hungry. They sleep outside, and he tells her to sleep away from him. He uses a thermal blanket(the first I ever saw in my life). She wakes up next to him, smelling horrible. He bathes her in some water hole they find(as if water were not scarce and they could just waste water.)   Pupa monsters:      Scene where they are in a building and they are trying to get out. They come across a room that is white, in which multiple giant, white, snot, pupa are hanging securely from the ceiling. Through curiosity, they disturb them, and now they have to get out of that room fast.  Boss Antagonist:      Pervert bionic man, that is actually attached to a giant robotic arm, as only form of movement. He is in black and has a pale bald head as his most human looking part. Need help with a question regarding the Big Oh In class we are currently covering upper/lower bounds, big Oh and omega and the like. I am pretty good on the "typical" functions one would do, but at a complete loss at "general" statements. This ons function, for example:  $$\forall f\in\mathcal{F}: \lfloor \sqrt{\lfloor f(n)\rfloor }\rfloor \in O(\sqrt{f(n)}).$$  the domain F by the same is all natural numbers that return a real positive number when inputted. My first instinct with something like this is to remove the floors, the general strategy I though to solve this is remove the outer floor, then get rid of the square root, and then the inner floor. But I have no idea how to go about this or if this is even the right way to do it.  Help please? Thanks in advance. Proving that $\left( \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} \right) \lvert f(z) \rvert^2 = 4 \lvert f'(z) \rvert^2$ Given $f$ entire show that $$ \left( \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} \right) \lvert f(z) \rvert^2 = 4 \lvert f'(z) \rvert^2 $$ I've come close to getting the exact answer by writing $f(z)$ as $u(x,y)+iv(x,y)$ and realizing the Laplacian of f is equal to zero. This leads to a lot of cancellations but I'm still making mistakes in my computations and I can't figure out where. Any help is appreciated.