diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 2bb0b7b69d1600462abe1b484ee8305379c8d93d..c1797c5f8ec0b5d96a91386e38392e14b543b1eb 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -1875,31 +1875,25 @@ namespace pugi
 	
 	xml_attribute& xml_attribute::operator=(int rhs)
 	{
-		char buf[128];
-		sprintf(buf, "%d", rhs);
-		set_value(buf);
+		set_value(rhs);
 		return *this;
 	}
 
 	xml_attribute& xml_attribute::operator=(unsigned int rhs)
 	{
-		char buf[128];
-		sprintf(buf, "%u", rhs);
-		set_value(buf);
+		set_value(rhs);
 		return *this;
 	}
 
 	xml_attribute& xml_attribute::operator=(double rhs)
 	{
-		char buf[128];
-		sprintf(buf, "%g", rhs);
-		set_value(buf);
+		set_value(rhs);
 		return *this;
 	}
 	
 	xml_attribute& xml_attribute::operator=(bool rhs)
 	{
-		set_value(rhs ? "true" : "false");
+		set_value(rhs);
 		return *this;
 	}
 
@@ -1925,6 +1919,32 @@ namespace pugi
 		return res;
 	}
 
+	bool xml_attribute::set_value(int rhs)
+	{
+		char buf[128];
+		sprintf(buf, "%d", rhs);
+		return set_value(buf);
+	}
+
+	bool xml_attribute::set_value(unsigned int rhs)
+	{
+		char buf[128];
+		sprintf(buf, "%u", rhs);
+		return set_value(buf);
+	}
+
+	bool xml_attribute::set_value(double rhs)
+	{
+		char buf[128];
+		sprintf(buf, "%g", rhs);
+		return set_value(buf);
+	}
+	
+	bool xml_attribute::set_value(bool rhs)
+	{
+		return set_value(rhs ? "true" : "false");
+	}
+
 #ifdef __BORLANDC__
 	bool operator&&(const xml_attribute& lhs, bool rhs)
 	{
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 6228b79a3456416ba67dfc8c7277e406c7044f51..0b141488abae4a6ed8b20d4c3dda6fceb8ff50ea 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -583,6 +583,38 @@ namespace pugi
 		 */
 		bool set_value(const char* rhs);
 
+		/**
+		 * Set attribute value to \a rhs.
+		 *
+		 * \param rhs - new attribute value
+		 * \return success flag (call fails if attribute is empty or there is not enough memory)
+		 */
+		bool set_value(int rhs);
+
+		/**
+		 * Set attribute value to \a rhs.
+		 *
+		 * \param rhs - new attribute value
+		 * \return success flag (call fails if attribute is empty or there is not enough memory)
+		 */
+		bool set_value(unsigned int rhs);
+
+		/**
+		 * Set attribute value to \a rhs.
+		 *
+		 * \param rhs - new attribute value
+		 * \return success flag (call fails if attribute is empty or there is not enough memory)
+		 */
+		bool set_value(double rhs);
+
+		/**
+		 * Set attribute value to either 'true' or 'false' (depends on whether \a rhs is true or false).
+		 *
+		 * \param rhs - new attribute value
+		 * \return success flag (call fails if attribute is empty or there is not enough memory)
+		 */
+		bool set_value(bool rhs);
+
 	public:
 		/**
 		 * Check if attribute is empty.